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

19 lines
378 B
Plaintext

```js
// /my-addon/manager.js
import React from 'react';
import { STORY_CHANGED } from '@storybook/core-events';
export const Panel = () => {
const emit = useChannel({
STORY_CHANGED: (...args) => console.log(...args),
});
return (
<button onClick={() => emit('my-event-type', { some: 'data' })}>
clicking this will emit an event
</button>
);
};
```