I am new to React and was struggling with where we need to keep state in React. I came across an example which puts state in parent component and get access to that state via props. That is, there is Accordion component and the Accordion is either in the “open” state, or the “closed” state, and we store that information as a flag inside the parent component’s state (not inside the Accordion). We tell the Accordion which way to render by passing isOpen as a prop. When isOpen is true, it renders as open. When isOpen is false, it renders as closed.
*The question is Why do we need to keep state in parent component since we can keep state in Accordion component and manage it in there. *