Answer the question
In order to leave comments, you need to log in
Is it possible to store a component in React state?
I'm learning React on a test project.
There is a component Exercise
and its children Set
.
When adding a new Set
one, it is written to the array: this.state.sets()
But today I heard that this should not be done, but I did not find out the details. Is it possible to store other Components in a State? If not, why not?
Demo&Component code: https://codesandbox.io/s/inspiring-haze-uycjb?file...
Illustration:
Answer the question
In order to leave comments, you need to log in
Storing a component is a derived state and therefore bad practice.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question