Skip to content
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

General Notes Client Side - React #55

Open
Nizar7zak opened this issue Apr 14, 2022 · 0 comments
Open

General Notes Client Side - React #55

Nizar7zak opened this issue Apr 14, 2022 · 0 comments

Comments

@Nizar7zak
Copy link

Nizar7zak commented Apr 14, 2022

<NotFound />

Avoid console.log and commented Lines in your codes, you missed handle the login state, your users can add to cart without login. and the login button didn't work !

some issue i saw it in your code...

  componentDidMount() {
    const { id, buttons , changeCart} = this.props;
    if(typeof buttons === 'string'){
    const products = JSON.parse(localStorage.getItem('products'));
    const addedToCart = products.some(item => item.id === id);
    this.setState({ addedToCart });
    changeCart(products.length)

  }

why we use component did mount here? I advice you to read this essay about local storage and what is the max size we can store in Local storage, should pass this data from parent component is better than this way. we can pass all data we need as props,

componentDidMount we use it when we have a http request in this component.

In contrast you did a great work and applied the concept of State and how we handle it very good, moreover you separate your components VERY GOOD.

GREAT WORK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant