-
-
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 React Profiler in source snippets #19004
Addon-docs: Fix React Profiler in source snippets #19004
Conversation
+ test: fixed dead unit tests.
@@ -101,6 +101,7 @@ export const renderJsx = (code: React.ReactElement, options: JSXOptions) => { | |||
// To get exotic component names resolving properly | |||
displayName: (el: any): string => | |||
el.type.displayName || | |||
(el.type === Symbol.for('react.profiler') ? 'Profiler' : null) || |
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.
the major change here!
@@ -141,7 +142,7 @@ export const renderJsx = (code: React.ReactElement, options: JSXOptions) => { | |||
return string; | |||
}).join('\n'); | |||
|
|||
return result.replace(/function\s+noRefCheck\(\)\s+\{\}/, '() => {}'); | |||
return result.replace(/function\s+noRefCheck\(\)\s+\{\}/g, '() => {}'); |
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.
const Template: ComponentStory<typeof Button> = (args) =>
<Profiler id="test" onRender={() => console.log('test-profiler')}>
<Button {...args} />
</Profiler>
export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/react/writing-stories/args
Primary.args = {
primary: true,
label: 'Button',
onClick: () => console.log('test-button')
};
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.
It still isn't showing the actual function. Is that the expected behavior?
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, @zhyd1997! This is an amazing first-time contribution! 🥳
Would you mind checking to see if the change related to noRefCheck
is tested, and adding a test, if not. Thanks!
@@ -87,7 +87,7 @@ describe('Extracting Arguments', () => { | |||
"control": Object { | |||
"type": "boolean", | |||
}, | |||
"description": null, |
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.
@zhyd1997 — Can you please share why this change was necessary?
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.
I didn't change svelte code, and I think they 're all falsy value, so I just ran something like update-snapshots
command.
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.
Previously we didn't enable code/renderers
unit test after moved all source code into code
folder, but I need run unit test for react
, so I manually enabled it in this PR, but svelte
unit test failed, that's why I updated all code/renders
snapshots here.
I need to add a story to test it, |
Any news on this issue? It would be awesome if we can gave good code export functionality. Thank you! |
merge the latest upstream commits into this branch.
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.
Thank you @zhyd1997 !!! 🙌
Is this fix available in any version of |
Sorry no, available from this version: v7.0.0-alpha.46 |
Issue: #11554
What I did
code/renderers
unit tests.How to test
If your answer is yes to any of these, please make sure to include it in your PR.