-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
docs: add information about @storybook/preview-api useArgs hook #22590
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2a9b09e
docs: add information about @storybook/preview-api useArgs hook
jonthenerd 9e5f981
docs: fix issue with code sample
jonthenerd b701f0f
docs: fix code block - remove unnecessary export
jonthenerd aade9cc
docs: now passes eslint
jonthenerd 1d54130
docs: change code block to be minimum example that does not cause esl…
jonthenerd d12518c
docs: fix typo in header
jonthenerd 665c1a8
docs: align code pattern to ensure no eslint or storybook issues
jonthenerd 449b052
make changes per recommendations
jonthenerd cec4576
fix typos; align style to other js code snippets
jonthenerd 8add32d
fix mispelling in comments
jonthenerd c3ea9cd
Merge branch 'next' into patch-1
jonniebigodes ed5bd70
Merge branch 'next' into patch-1
jonthenerd f9e2e0d
add typescript 4.9 snippet
jonthenerd 44fa3c3
removed added file. Why wasn't this excluded via .gitignore???
jonthenerd 504fefa
modify text to align to pull request comment
jonthenerd 522bb81
Merge branch 'next' into patch-1
jonthenerd 41d8edf
remove link to incorrect api
jonthenerd 91cce63
Merge branch 'next' into patch-1
jonniebigodes 78ae771
Merge branch 'next' into patch-1
jonthenerd eea29bc
add react IFRenderer to args docs addition
jonthenerd d9a0caa
Merge branch 'next' into patch-1
jonthenerd 0cacd64
Merge branch 'next' into patch-1
jonniebigodes 106bf9a
Merge branch 'next' into patch-1
jonniebigodes 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| ```js | ||
| // my-component/component.stories.js|jsx | ||
|
|
||
| import { useArgs } from '@storybook/preview-api'; | ||
| import { Switch } from '.'; | ||
|
|
||
| export default { | ||
| title: 'Inputs/Switch', | ||
| component: Switch, | ||
| }; | ||
|
|
||
| export const Example = { | ||
| args: { | ||
| isChecked: false, | ||
| label: 'Switch Me!', | ||
| }, | ||
| /** | ||
| * 👇 React believes the Storybook function "useArgs" is a hook, but it's really not. | ||
| * Using a named capital-letter function prevents an ESLint warning related to this. | ||
| * Don't lint? You can use an arrow function instead. | ||
| */ | ||
| render: function Render(args) { | ||
| const [{ isChecked }, updateArgs] = useArgs(); | ||
|
|
||
| function onChange() { | ||
| updateArgs({ isChecked: !isChecked }); | ||
| } | ||
|
|
||
| return <Switch {...args} onChange={onChange} isChecked={isChecked} />; | ||
| }, | ||
| }; | ||
| ``` | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| ```ts | ||
jonniebigodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // my-component/component.stories.ts|tsx | ||
|
|
||
| import { StoryObj, Meta } from '@storybook/react'; | ||
| import { useArgs } from '@storybook/preview-api'; | ||
| import { Switch } from '.'; | ||
|
|
||
| const meta: Meta<typeof Switch> = { | ||
| title: 'Inputs/Switch', | ||
| component: Switch, | ||
| }; | ||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof Switch>; | ||
|
|
||
| export const Example = { | ||
| args: { | ||
| isChecked: false, | ||
| label: 'Switch Me!', | ||
| }, | ||
| /** | ||
| * 👇 React believes the Storybook function "useArgs" is a hook, but it's really not. | ||
| * Using a named capital-letter function prevents an ESLint warning related to this. | ||
| * Don't lint? You can use an arrow function instead. | ||
| */ | ||
| render: function Render(args) { | ||
| const [{ isChecked }, updateArgs] = useArgs(); | ||
|
|
||
| function onChange() { | ||
| updateArgs({ isChecked: !isChecked }); | ||
| } | ||
|
|
||
| return <Switch {...args} onChange={onChange} isChecked={isChecked} />; | ||
| }, | ||
| }; | ||
| ``` | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.