React redux和firebase删除onAuthStateChanged侦听器

时间:2018-06-18 11:29:18

标签: reactjs firebase redux firebase-authentication redux-thunk

我使用React,Redux和Firebase对用户进行身份验证。

我已添加到我的组件生命周期ComponentWillMount

dispatch(onAuthStateChanged())来执行此侦听器。

以及我对中间件thunk的行为

export const onAuthStateChanged = () => dispatch => {
  auth.onAuthStateChanged(
    () => {
      dispatch({ type: CURRENT_USER, currentUser: auth.currentUser });
    },
    error => {
      //system error
    }
  );
};

有没有人知道如何使用componentWillUmount移除此侦听器?

0 个答案:

没有答案