-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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);
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.