Skip to content Skip to sidebar Skip to footer

React Props Are Updating Even When I'm Not Using The Props

I made a project using the create-react-app template. I am trying to import data from a JSON file and send it to the todos component file as props but I'm not using it as a prop in

Solution 1:

Whenever state change component re-renders and here you have parent and child component.

In your parent component you are updating your lists that's why child also getting re-render whether you are passing changes or not. I will happen.

To prevent this, you need to use shouldComponentUpdate, React.memo or PureComponent.

For your reference to understand scenario and with example.

Whenever you call method setState(), component automatically re-renders

How to prevent unnecassery re-rendering

Post a Comment for "React Props Are Updating Even When I'm Not Using The Props"