Meteor setInterval道具不';t更新
我在下面的代码中发送操作。在这个动作中,我有loggingIn==false,但是this.props.loggingingin==true。 如何修复它 component.jsMeteor setInterval道具不';t更新,meteor,redux,react-redux,Meteor,Redux,React Redux,我在下面的代码中发送操作。在这个动作中,我有loggingIn==false,但是this.props.loggingingin==true。 如何修复它 component.js updateProfile() { return { user: Meteor.user(), loggingIn: Meteor.loggingIn() } } componentWillMount() { this.props.loadUser(this.updateProfile());
updateProfile() {
return { user: Meteor.user(), loggingIn: Meteor.loggingIn() }
}
componentWillMount() {
this.props.loadUser(this.updateProfile());
debugger;
this.data = setInterval(() => {
if(this.props.loggingIn === true) {
this.props.loadUser(this.updateProfile());
}
}, 1000);
}
export const loadUser = ({user, loggingIn}) => dispatch => {
dispatch({
type: 'USER_DATA',
payload: user
})
dispatch({
type: 'USER_LOGGING_IN',
payload: loggingIn
});
};
actions.js
updateProfile() {
return { user: Meteor.user(), loggingIn: Meteor.loggingIn() }
}
componentWillMount() {
this.props.loadUser(this.updateProfile());
debugger;
this.data = setInterval(() => {
if(this.props.loggingIn === true) {
this.props.loadUser(this.updateProfile());
}
}, 1000);
}
export const loadUser = ({user, loggingIn}) => dispatch => {
dispatch({
type: 'USER_DATA',
payload: user
})
dispatch({
type: 'USER_LOGGING_IN',
payload: loggingIn
});
};
您应该使用redux thunk进行异步调用。下面是使用的教程 和一个处理用户信息的示例代码