我正在使用 Storybook 在纯 HTML、CSS 和 JS(实际上是 jQuery)中创建组件。
我想知道在屏幕上呈现故事时是否有回调函数(例如useEffectReact),因为只有当组件确实在 DOM 中时我才需要运行相关的 jQuery 代码。
这是我的情况:
// Button.stories.js
// my pure HTML component
const Button = () => `<button>My button </button>`;
export default {
title: 'Buttons',
};
export const ButtonStory = () => Button()
// would be great something like: ButtonStory.callback = function(){ do this}
有没有解决方法的东西?(比如将 HTML 组件包装在 react 组件中并使用 useEffect 来触发代码)