M
M
Mark2021-10-19 15:13:20
React
Mark, 2021-10-19 15:13:20

Is it possible to store a component in React state?

I'm learning React on a test project.

There is a component Exerciseand its children Set.
When adding a new Setone, 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:
byHt20L.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexandroppolus, 2021-10-19
@Alexandroppolus

Storing a component is a derived state and therefore bad practice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question