Javascript Storybook调用函数,它是组件的一个道具
我有一个组件“Item”和一个容器。容器有一个延迟加载函数,我用它加载项目。因此,我必须触发该函数,以显示项目。如何触发storybook中的函数Javascript Storybook调用函数,它是组件的一个道具,javascript,reactjs,storybook,Javascript,Reactjs,Storybook,我有一个组件“Item”和一个容器。容器有一个延迟加载函数,我用它加载项目。因此,我必须触发该函数,以显示项目。如何触发storybook中的函数 // Container.js with Item component <Item key={post.id} lazyLoading={this.lazyloading.bind(this)} //I need to trigger this function, to load the
// Container.js with Item component
<Item
key={post.id}
lazyLoading={this.lazyloading.bind(this)} //I need to trigger this function, to load the posts
text={this.props.text}
styles={this.props.styles}
/>
// Item.stories.js
let key = 1;
let text = "test";
let styles = {
backgroundColor: 'red',
}
storiesOf('Item', module).add(
'default',
(() => (
<Item
key={key}
text={text}
styles={styles}
lazyLoadingImage={} // How can I call this function?
/>
))
);
//带有项组件的Container.js
//Item.stories.js
设key=1;
让text=“test”;
让样式={
背景颜色:“红色”,
}
storiesOf('项目',模块)。添加(
“默认值”,
(() => (
))
);