【发布时间】:2017-04-03 15:29:43
【问题描述】:
我正在尝试将 firebase 与 React-Native / Redux 一起使用,我需要在每次用户登录或注销时调度一个操作。如何从根组件调度操作?
class App extends Component {
componentWillMount() {
firebase.auth().onAuthStateChanged((user) => {
if (user) {
// Dispatch Action here
} else {
// Disptach Action here
}
});
}
render() {
const store = createStore(reducers, {}, applyMiddleware(ReduxThunk));
return (
<Provider store={store}>
<Router />
</Provider>
);
}
}
export default App;
【问题讨论】:
标签: reactjs firebase react-native redux firebase-authentication