我使用React,Redux和Firebase对用户进行身份验证。
我已添加到我的组件生命周期ComponentWillMount
中dispatch(onAuthStateChanged())来执行此侦听器。
以及我对中间件thunk的行为
export const onAuthStateChanged = () => dispatch => {
auth.onAuthStateChanged(
() => {
dispatch({ type: CURRENT_USER, currentUser: auth.currentUser });
},
error => {
//system error
}
);
};
有没有人知道如何使用componentWillUmount移除此侦听器?