-
-
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
Addon-docs: Fix exotic React components in Source block #12638
Conversation
…/ memo & forwardRef exotic components Prev. would just do as <[object Object]>.. because it didn't know where to lookup the inner render function's name.
5efc1ff
to
77ec4c6
Compare
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.
Hey @andezzat !! Thanks so much for putting this together -- will make a ton of people happy. Unfortunately, I added a test case to official-storybook
and it doesn't seem to be working end-to-end. You can find that in the latest commit on this branch.
Would you mind:
- looking into this specific case
- adding more test cases to official-storybook
- reconciling the official-storybook behavior and the jest test cases (look great, but somehow don't line up)
…xample Component should be fed directly to React.memo|forwardRef functions so that displayName is set. Previously was passing an anonymous arrow fn...
examples/official-storybook/stories/addon-docs/react-forward-ref.stories.js
Outdated
Show resolved
Hide resolved
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.
LGTM! 💯 💯 💯
Addon-docs: Fix exotic React components in Source block
This appears to be broken: It seems to originate from export const ForwardRefButtonInnerPropTypes = forwardRef(BaseButton);
|
cc @andezzat can you take a look ☝️ |
Ah yes, I should've made a new component w/ proper |
The Problem
React Memo & ForwardRef exotic components would show up in the code snippet of storybook as
<[object Object]>
because it didn't know where to lookup the inner render function's name.This is a bug in the library Storybook uses to render JSX into a string: algolia/react-element-to-jsx-string#352
What I did
I stole the default
displayNameFn
from the original library hereAnd added what it needed to fetch Memo & ForwardRef component's names.
How to test
Maybe? I have no idea
No
No
If your answer is yes to any of these, please make sure to include it in your PR.