【发布时间】:2016-04-05 16:28:40
【问题描述】:
我需要在主组件时设置间隔。 我尝试在构造函数中设置它,例如
constructor(props) {
super(props);
this.props.fetchUserInfo();
this.props.fetchProducts();
setInterval(console.log('1'), 1000);
}
或在componentDidMount内部
componentDidMount = () => {
setInterval(console.log('1'), 1000);
};
但它总是记录一次“1”。如何正确启动间隔?
【问题讨论】:
标签: javascript reactjs