-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Story types: fix StoryFns used as React components #75472
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
base: trunk
Are you sure you want to change the base?
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 3.02 MB ℹ️ View Unchanged
|
| render: Template, | ||
| args: { | ||
| colors: [ | ||
| { name: 'Red', color: '#f00' }, | ||
| { name: 'White', color: '#fff' }, | ||
| { name: 'Blue', color: '#00f' }, | ||
| ], | ||
| value: '#00f', | ||
| }, |
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.
Could we simplify these to properly extend the default story? (Same question applies to other stories in these files)
| render: Template, | |
| args: { | |
| colors: [ | |
| { name: 'Red', color: '#f00' }, | |
| { name: 'White', color: '#fff' }, | |
| { name: 'Blue', color: '#00f' }, | |
| ], | |
| value: '#00f', | |
| }, | |
| ...Default, | |
| args: { | |
| ...Default.args, | |
| value: '#00f', | |
| }, |
Spinoff from the React 19 upgrade in #61521 that fixes some storybook types. The problem is that a function of type
StoryFncan no longer be used as a React component:StoryFnis somewhat compatible, it has apropsfirst argument and a secondcontextargument that wouldn't be used. But React 19 types are more strict than before and reject this.I refactored the three story files where this was a problem:
FontSizePickerWithStateare now regular React components, not stories.StoryFnfunctions usages were refactored toStoryObjobjects. Seems to be like a more elegant pattern which avoids creating mutliple copies of a story function with.bind({}).