issues
search
sidnt
/
zarn
zio & react native
0
stars
0
forks
source link
setState()
#1
Open
sidnt
opened
4 years ago
sidnt
commented
4 years ago
enqueues changes to component state
would all children components be re-rendered with the updated parent state, as well?
is a request rather than an immediate command to update the component
react does not guarantee that the requested changes are applied immediately
doesn't always immediately update the component
may batch or defer the update for later
immediately after calling
setState()
, it's unsound to expect the latest state via
this.state
componentDidUpdate
or the setState callback is guaranteed to fire, after the update has been applied
setState's updater argument can be used to compute new state based on old one
usage guidelines
This is the primary method you use to update the user interface in response to event handlers and server responses.
If the next state depends on the current state, we recommend using the updater function form, instead
setState()
, it's unsound to expect the latest state viathis.state
componentDidUpdate
or the setState callback is guaranteed to fire, after the update has been appliedusage guidelines