A
A
AlinaCat2019-02-27 06:50:35
React
AlinaCat, 2019-02-27 06:50:35

Questions from a newbie on state?

I read tutorials, everything is clear with props, but I don’t understand why state is needed until the end
1) what is its meaning if it is written in one sentence? Those. it’s clear that to keep the actual data, but then I don’t see the difference with the usual state object in native js, which you can create yourself for the same purposes.
2) does a component always have a state object? In one place it is written that it is always, in another - there are stateless components.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Okhotnikov, 2019-02-27
@AlinaCat

The component is redrawn when the state changes (mutates), it is not just an object with data. State is not always there, data can be received from the parent via props, or the component may not receive or store data at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question