Lets say I have a parent component called and I create a useState in it called [value, setValue]. I pass the value and setValue to a child component through props. Please note that the function setState is not used in the parent component and the state ‘value’ is not used in the JSX of the parent. Value is used in the JSX of the child component and and setValue is also used in the child component. Here the child component will definitely re-render when the setValue is used, does the parent component re-render or no?
I did try creating a sample project testing things out myself, I found that both the parent and child component re-rendered twice. I do not understand why this is happening, perhaps I don’t understand how does re-rendering actually work in React.
Please help me solve this confusion.