Pete's answer is great.
Backbone models are inherently mutative, which (while not a problem in itself) means that when rerendering, you won't have the old version of the model to compare to. This makes it harder to do intelligent optimizations by defining shouldComponentUpdate
methods in key places on your components. (You also lose out on the ability to easily store old versions of your model for other reasons, like implementing undo.)
Calling forceUpdate
merely skips shouldComponentUpdate
and forces the component to rerender. Note that calling render
is usually cheap, and React will still only touch the DOM if the output of render
has changed, so performance problems here aren't common. However, if you have the choice to use immutable data (including passing around raw model property objects from toJSON()
as Pete suggests), I'd highly recommend it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…