storybook/docs/snippets/common/storybook-addons-api-useglobal.js.mdx
2022-03-18 10:27:04 +01:00

19 lines
393 B
Plaintext

```js
// /my-addon/manager.js
import React from 'react';
import { useGlobals } from '@storybook/api';
export const Panel = () => {
const [globals, updateGlobals] = useGlobals();
const isActive = globals['my-param-key'] || false;
return (
<button onClick={() => updateGlobals({ ['my-param-key']: !isActive })}>
{isActive ? 'Hide me!' : 'Show me!'}
</button>
);
};
```