mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-20 05:02:37 +08:00
19 lines
513 B
Plaintext
19 lines
513 B
Plaintext
```js
|
|
// /my-addon/manager.js
|
|
|
|
import React from 'react';
|
|
|
|
import { useAddonState } from '@storybook/manager-api';
|
|
|
|
export const Panel = () => {
|
|
const [state, setState] = useAddonState('my/addon-id', 'initial state');
|
|
|
|
return <button onClick={() => setState('a new value')}>the state = "{state}"</button>;
|
|
};
|
|
export const Tool = () => {
|
|
const [state, setState] = useAddonState('my/addon-id', 'initial state');
|
|
|
|
return <button onClick={() => setState('a new value')}>the state = "{state}"</button>;
|
|
};
|
|
```
|