-
-
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
Merged
shilman
merged 14 commits into
storybookjs:next
from
zhyd1997:fix/support-profiler-use-in-component
Oct 27, 2022
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
83799d9
fix: supported React.Profiler use in component.
zhyd1997 ab720ae
fix: typo
zhyd1997 876778d
test: typo.
zhyd1997 718886f
test: close tag.
zhyd1997 c25ada4
test: added renderers dir to jest work path.
zhyd1997 8cdcfee
test: updated snapshots.
zhyd1997 40d1da0
test: done Profiler test.
zhyd1997 62f77ce
fix: replaced 'function noRefCheck() {}' *globally*.
zhyd1997 b26e121
test: added noRefCheck story test file.
zhyd1997 2e1340b
Merge branch 'storybookjs:next' into fix/support-profiler-use-in-comp…
zhyd1997 47708a4
Merge branch 'next' into fix/support-profiler-use-in-component
zhyd1997 9f3c1fa
Merge branch 'storybookjs:next' into fix/support-profiler-use-in-comp…
zhyd1997 c46aa2b
fix: deleted examples/cra-ts-kitchen-sink folder.
zhyd1997 117fab9
Merge branch 'storybookjs:next' into fix/support-profiler-use-in-comp…
zhyd1997 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,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) || | ||
getDocgenSection(el.type, 'displayName') || | ||
(el.type.name !== '_default' ? el.type.name : null) || | ||
(typeof el.type === 'function' ? 'No Display Name' : null) || | ||
|
@@ -119,7 +120,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 commentThe 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 commentThe 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? |
||
}; | ||
|
||
const defaultOpts = { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!