-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Show real sources instead of "compiled" source with HoC #938
Comments
Comment by tleunen @dimaip There's an easy way to fix the issue, what I've been using now for these components is something like: import RealComponent from '../';
const MyComponent = props => <RealComponent {...props}>{props.children}</RealComponent>;
// then just use `MyComponent` |
Comment by gnarf You can also use //and MyComp.js, something like:
function enhance(Component) {
class EnhanceComp extends React.Component {
render() {
return <Component>super enhanced</Component>
}
};
// default enhancment, just decorate the display name of the parent component
EnhanceComp.displayName = `Enhanced(${Component.displayName || Component.name})`;
return EnhanceComp;
}
const MyWrappedComp = ({children}) => {
return <div>My {children} Component</div>
};
const enhanced = enhance(MyWrappedComp);
// we want this to look like a normal <MyComp>
enhanced.displayName = 'MyComp'; |
Comment by gnarf I was digging into using the "real" source - but it's basically impossible unless you separate each story into it's own storiesOf('MyComponent')
.addWithInfo('default', `
### Source:
\`\`\`js
${require('!!raw-loader!./MyComponent/default.js')}
\`\`\`
`, require('./MyComponent/default.js')) Found out it works, but how much do we REALLY want that? :) |
Comment by gnarf This is the more generalized code I was using in my storybook index.js: https://gist.github.com/gnarf/ea9bd0f76e36516b6f1f38e4aba542a3 I'm using this to export real "example code" for the story |
Comment by mnmtanish
|
Comment by darioghilardi I just pushed #127 trying to provide a solution for this issue. If you want to provide some feedback it would be great. |
@mnmtanish I wonder why it's a bad idea? |
@darioghilardi can you explain your suggested solution here? |
can't we add an option like a displayName? it'd be an analogous design to the current |
Hi @ndelangen, |
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 60 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! |
Issue by tleunen
Friday Sep 16, 2016 at 13:49 GMT
Originally opened as storybook-eol/react-storybook-addon-info#73
At first, I thought the plugin was showing the real sources of a story (the exact code that a story contains), but in fact it's showing the sources from the used components, or compiled sources.
Lets say I have this code and this story:
but if MyComp is actually something using HoC, the rendering won't be
<MyComp />
but<EnhanceComp />
It would be best to keep showing
MyComp
instead because that's what users should use.The text was updated successfully, but these errors were encountered: