storybook-addon-playground
Version:
A playground to enable consumers learn how to use the component library or to reproduce bugs
19 lines (16 loc) • 642 B
JavaScript
import { DEFAULT_ADDON_STATE } from '../consts/state-consts.js';
import { PLAYGROUND_EDITOR_CHANGED } from '../consts/events-consts.js';
import '@codemirror/commands';
import { useState, useCallback, useChannel } from '@storybook/preview-api';
const usePlaygroundPreviewCode = () => {
const [code, setCode] = useState(DEFAULT_ADDON_STATE.code);
const onEditorChange = useCallback((newCode) => {
setCode(newCode);
}, []);
useChannel({
[PLAYGROUND_EDITOR_CHANGED]: onEditorChange,
});
return code;
};
export { usePlaygroundPreviewCode as default };
//# sourceMappingURL=usePlaygroundPreviewCode.js.map