Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alfina Megasiwi
Walkiddie Toys - FrontEnd
Commits
e161028c
Commit
e161028c
authored
Mar 31, 2021
by
Naufal Alauddin Hilmi
🍦
Browse files
[GREEN] prerender fetch user
parent
3166807e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/App.js
View file @
e161028c
...
...
@@ -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
>
...
...
src/reducer/auth.js
View file @
e161028c
...
...
@@ -39,6 +39,7 @@ function reducer(state = initialState, action) {
case
USER_LOADED_SUCCESS
:
return
{
...
state
,
isAuthenticated
:
true
,
user
:
payload
}
case
USER_LOADED_FAIL
:
...
...
src/util/prerender.js
0 → 100644
View file @
e161028c
import
{
load_user
}
from
'
../actions/auth
'
;
export
const
fetch_user
=
async
(
store
)
=>
{
if
(
localStorage
.
getItem
(
'
access
'
))
{
load_user
()(
store
.
dispatch
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment