1

I have a child component that is getting rendered on App.js (parent) with its own state as it is not dependent on the parent state. Is this good practice? Or should props be used?

2 Answers2

0

The React documentation describes the process of Lifting State Up in which they suggest that indeed, as a general practice, state should be lifted up (e.g., into the parent) and given to children as props.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
0

It really depends on what the use of your child component is. If the component only uses a few props to render, there is no use for a class based component with its own state. If the component needs more functionality (states etc) you are better of using a class based component.

Also, if your component have a few child components which are dependent on their parent it could be appropriate using state.

I think this question is relevant to what you are asking.

Bastmark
  • 28
  • 5