Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Converted App.js from class based component to functional component#158

Open
arunmishra2000 wants to merge 2 commits into
jmprathab:masterfrom
arunmishra2000:master
Open

Converted App.js from class based component to functional component#158
arunmishra2000 wants to merge 2 commits into
jmprathab:masterfrom
arunmishra2000:master

Conversation

@arunmishra2000

Copy link
Copy Markdown

No description provided.

Comment thread src/App.js
Comment on lines +79 to 90
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,
});

Copy link
Copy Markdown

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

@alaahatem alaahatem Nov 14, 2021

Copy link
Copy Markdown

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
        });

Comment thread src/App.js
Comment on lines +99 to +101
const onMenuToggle = () => {
setOverlay(!overlay);
};

Copy link
Copy Markdown

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 alaahatem left a comment

Copy link
Copy Markdown

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants