-
Notifications
You must be signed in to change notification settings - Fork 70
Converted App.js from class based component to functional component #158
base: master
Are you sure you want to change the base?
Conversation
| const loadUserInfo = () => { | ||
| // Get user details from localStorage and save to react store | ||
| try { | ||
| var info = localStorage.getItem("userInfo"); | ||
| let info = localStorage.getItem("userInfo"); | ||
| if (info) { | ||
| let userInfo = JSON.parse(info); | ||
| console.log("Loaded UserId from storage : " + userInfo.userId); | ||
| console.log("Loaded token from storage : " + userInfo.token); | ||
| this.props.setCurrentUser({ | ||
| props.setCurrentUser({ | ||
| userId: userInfo.userId, | ||
| token: userInfo.token, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be better if we just destructure the user info and use it to set the current user . use const instead of var or let
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try {
const info = localStorage.getItem("userInfo");
if (info) {
const {userId , token) = JSON.parse(info);
console.log("Loaded UserId from storage : " + userInfo.userId);
console.log("Loaded token from storage : " + userInfo.token);
this.props.setCurrentUser({
props.setCurrentUser({
userId,
token
});
| const onMenuToggle = () => { | ||
| setOverlay(!overlay); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to
const onMenuToggle = () => setOverlay(!overlay);
alaahatem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Job but think some changes need to be applied first
No description provided.