-
-
Notifications
You must be signed in to change notification settings - Fork 9.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
Docs default props aren't working with ES6 default values #9626
Comments
Thanks @smithambera. We'll be doing an overhaul of the props handling code in 6.0 and hopefully can handle this case. FYI, unrelated to this problem, but please upgrade your |
Thanks for responding so quickly, @shilman! I'm looking forward to 6.0 😄 and thanks for the tip, too - upgraded the packages! |
This appears to be working in an isolated test: 3cfe6e1 |
ES6 default values worked for me as well, but when I started using React.forwardRef the default props stopped working. Using the same example as above - this does not work: const Tag = React.forwardRef(({ title = 'Beta' }, ref) => <TagWrapper ref={ref}>{title}</TagWrapper>); This works: const Tag = React.forwardRef(({ title = 'Beta' }, ref) => <TagWrapper ref={ref}>{title}</TagWrapper>);
Tag.defaultProps = {
title: 'Beta'
}; |
@shilman Gotcha, thanks for the quick response! |
What if you write it like this: export const Tag = (props) => {
const { title = 'Beta' } = props;
return React.createElement("div", null, title);
};
export const component = Tag; Or even: export const Tag = (props) => {
return <div {...props />;
};
export const component = Tag; It might be neccesary to maintain access to the full |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Tag.defaultValues = {
foo: 'bar',
...
} |
@shilman That will add runtime overhead, because at runtime, |
@thany taking a very different approach in 6.0 that will address this issue |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
@thany new customization options documented here for 6.0. will get a few tweaks before final release, but hopefully nothing big: https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/props-tables.md#customizing-argtypes |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
@shilman Whats the solution here? I'm not seeing a way for Controls to register default props via es6 defaults. |
@jpmarra starting in 6.0 the ArgsTable is completely configurable. If docgen doesn't successfully pick up your defaults, you can add them using |
Describe the bug
I'm using ES6 default values as opposed to
defaultProps
because the React team is deprecatingdefaultProps
in functional components (facebook/react#16210). The ES6 defaults are not showing up in the auto-generated Storybook docs.This code:
results in these docs:
While this code:
results in these docs:
To Reproduce
Create a functional component and use ES6 defaults to set default props. Look at the docs.
Expected behavior
See above.
Screenshots
See above.
Code snippets
See above.
System:
Additional context
That's all I've got!
The text was updated successfully, but these errors were encountered: