Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Seriously?!
of course it can. But in general, this is rather an exception to the rule and it is better to use setState ()
In short:
setState () writes data to this. state and causes rendering.
forceUpdate() does nothing, it just triggers a render. Basically a useless function, i.e. if neither props nor state have changed, then one fig will be rendered, the same thing. To be honest, it doesn’t even occur to me why this might be needed, except for some magical asynchronous crutches in render .
forceUpdate may be needed when working with localStorage, whose data does not make sense to duplicate in state (if this data is only rendered and not sent to the server, of course)
the only time forceUpdate was needed was to implement media queries on a project that needed ie8 support.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question