2017-01-26 16 views
0

私は下記のコードでアクションをディスパッチします。そして、アクションでは、loggingIn === falseが、this.props.loggingIn === trueになります。 修正方法?setInterval小道具は更新されません

component.jsあなたは非同期呼び出しのためにReduxの-サンクを使用する必要があります

export const loadUser = ({user, loggingIn}) => dispatch => { 
dispatch({ 
    type: 'USER_DATA', 
    payload: user 
}) 
dispatch({ 
    type: 'USER_LOGGING_IN', 
    payload: loggingIn 
}); 
}; 

答えて

0

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); 
} 

redux-thunk を使用するためのチュートリアルと、ユーザーを扱うためのコード例authentication in Meteor

関連する問題