-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NavigatorButton: Reuse Button types #47754
Conversation
For now I went with the simplest / laziest approach, but here's a few more considerations. When working on On one hand, it feels correct that we advertise all of On the other hand, could exposing all the props be problematic if, e.g, the consumer decides to render Maybe an option could be to re-use all props of Any thoughts? |
Flaky tests detected in ceb13a1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4114034401
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ciampo,
Good idea to refer to the <Button>
props for when it's a <button>
.
*/ | ||
children: ReactNode; | ||
}; | ||
export type NavigatorBackButtonProps = ButtonAsButtonProps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to simplify this!
10e08ed
to
ceb13a1
Compare
* `NavigatorButton`: Reuse `Button` types * CHANGELOG * Tweak README
Cherry-picked this PR to the wp/6.2 branch. |
What?
Part of #35744
Following up #46997 , this PR cleans up types in
NavigatorButton
by re-using types from theButton
componentWhy?
Clean up duplicated code
How?
Button
's types are complex, since the component can render as a<button />
or as a<a />
depending on which props are passed.Since
NavigatorButton
usesButton
with the assumption that it renders a<button />
(and never a<a />
), I decided to export aButtonPropsAsButton
type and reuse it inNavigatorButton
.Testing Instructions
There aren't any runtime changes, so everything should work as before if the project builds without TS errors.