I am currently learning React js, and the differences between props and States are apparent.
But will the change in data passed in the prop cause the component to re-render or will it still be static with the data passed initially?
I still have reservations on props values changes, if it does cause a re-render of the component(not changing the data within the components)?
CodePudding user response:
A change in props will cause a re-render.
If you do not want this you can use a state like this:
const Component = (props) => {
const [firstRenderProps] = useState(props);
firstRenderProps will always have the same value after a re-render