-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: adding useSharedState, useStoryState (#9566)
api: adding useSharedState, useStoryState
- Loading branch information
Showing
5 changed files
with
95 additions
and
36 deletions.
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import { Button } from '@storybook/react/demo'; | ||
import { useStoryState } from '@storybook/client-api'; | ||
|
||
export default { | ||
title: 'addons|useAddonState', | ||
}; | ||
|
||
export const storyState1 = () => { | ||
const [state, setState] = useStoryState<number>(10); | ||
|
||
return ( | ||
<div style={{ color: 'white' }}> | ||
Story counter: {state} | ||
<br /> | ||
<Button onClick={() => setState(state - 1)}>decrement</Button> | ||
<Button onClick={() => setState(state + 1)}>increment</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export const storyState2 = () => { | ||
const [state, setState] = useStoryState<number>(10); | ||
|
||
return ( | ||
<div style={{ color: 'white' }}> | ||
Story counter: {state} | ||
<br /> | ||
<Button onClick={() => setState(state - 1)}>decrement</Button> | ||
<Button onClick={() => setState(state + 1)}>increment</Button> | ||
</div> | ||
); | ||
}; |
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
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