You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.
The logic that sets skipRender to true, skipping a forceUpdate, checks to see if the current props and next props are shallow equal to each other with isObjectShallowModified. The business logic as I understand it is basically “if props are shallow modified, don’t call forceUpdate because React will update the component on its own.”
However, this assumption appears to be wrong as of React 16 when the value of one of those props is NaN, because while NaN !== NaN, apparently React’s own handling of NaN has changed, and React does not in fact update the component. The result is that if you pass NaN as a prop to any observer component, it will never update as a reaction to observables changing. E.g.
@observerclassFooextendsComponent{render(){return/* something that hits any number of observables */;}}// elsewhere<Foobar={NaN}/>// This instance of Foo will never update
I'm happy to fix this myself, but need some guidance. If we make isObjectShallowModified compare values of NaN as “not modified,” this will cause double rerenders in React 15 and below. Is that an acceptable tradeoff, or should we detect which version of React is being used?
The text was updated successfully, but these errors were encountered:
mobx-react/src/observer.js
Lines 140 to 142 in bc10762
The logic that sets
skipRender
to true, skipping aforceUpdate
, checks to see if the current props and next props are shallow equal to each other withisObjectShallowModified
. The business logic as I understand it is basically “if props are shallow modified, don’t callforceUpdate
because React will update the component on its own.”However, this assumption appears to be wrong as of React 16 when the value of one of those props is
NaN
, because whileNaN !== NaN
, apparently React’s own handling ofNaN
has changed, and React does not in fact update the component. The result is that if you passNaN
as a prop to any observer component, it will never update as a reaction to observables changing. E.g.Live example: https://www.webpackbin.com/bins/-KzQSm3N0aWfc_U2V1BZ
I'm happy to fix this myself, but need some guidance. If we make
isObjectShallowModified
compare values ofNaN
as “not modified,” this will cause double rerenders in React 15 and below. Is that an acceptable tradeoff, or should we detect which version of React is being used?The text was updated successfully, but these errors were encountered: