-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (33 loc) · 1.15 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from 'react';
import ReactDom from 'react-dom';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import { Router, Route, browserHistory } from 'react-router';
import { firebaseApp } from './firebase';
import { logUser } from './actions';
import reducer from './reducers';
import App from './components/App';
import SignIn from './components/SignIn';
import SignUp from './components/SignUp';
const store = createStore(reducer);
firebaseApp.auth().onAuthStateChanged(user => {
if (user) {
// console.log('user has signed in or up', user);
const { email } = user;
store.dispatch(logUser(email));
browserHistory.push('/app');
} else {
// console.log('user has signed out or still needs to sign in');
browserHistory.replace('/signin');
}
})
ReactDom.render(
<Provider store={store}>
<Router path="/" history={browserHistory}>
<Route path="/app" component={App} />
<Route path="/signin" component={SignIn} />
<Route path="/signup" component={SignUp} />
</Router>
</Provider>
, document.getElementById('root')
)