Fakultas Ilmu Komputer UI

Commit e161028c authored by Naufal Alauddin Hilmi's avatar Naufal Alauddin Hilmi 🍦
Browse files

[GREEN] prerender fetch user

parent 3166807e
......@@ -5,10 +5,12 @@ import Footer from './components/Footer/Footer';
import Home from './components/Home/Home';
import { Provider } from 'react-redux';
import Login from './page/Login';
import { fetch_user } from './util/prerender';
import store from './store';
function App() {
fetch_user(store);
return (
<Provider store={store}>
<Router>
......
......@@ -39,6 +39,7 @@ function reducer(state = initialState, action) {
case USER_LOADED_SUCCESS:
return {
...state,
isAuthenticated: true,
user: payload
}
case USER_LOADED_FAIL:
......
import { load_user } from '../actions/auth';
export const fetch_user = async (store) => {
if (localStorage.getItem('access')) {
load_user()(store.dispatch);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment