mobx 2.6.3.
I have a fairly complex chain of dependent values that can be simplified to this:
@observer
class Tmp extends React.Component<{}, {}> {
@observable
someValue = 0;
@action updateSomething() {
// ...
this.someValue = NaN;
}
render() {
this.updateSomething();
return <div>value is {this.someValue}</div>
}
}
const tmp = ReactDOM.render(<Tmp />, document.getElementById("root"));
setTimeout(action(() => tmp.someValue = 100), 1000);
The render function is called forever because it keeps trying to set someValue to NaN and thinks it has changed again. It works if updateSomething sets someValue to anything other than NaN. My guess is that this happens because NaN !== NaN so the check if the value is different would need to be before === after || (isNaN(before) && isNaN(after))

Nice find. You are most probably right.
_me hating javascript now_
As a temporarily work around, you could do that check yourself before assigning, but thanks for reporting!
As a temporarily work around, you could do that check yourself before assigning,
The fix for my problem was actually somewhere else; the value should never have become NaN in the first place; but the infinite loop was unexpected ;)
me hating javascript now
Well, to be fair this is how it works in any language that follows the IEEE standard; e.g. https://github.com/dmlloyd/openjdk/blob/jdk9/jdk9/jdk/src/java.base/share/classes/java/lang/Double.java#L550
Since this is strictly speaking "correct", this could be considered not to be a bug... not sure lol. Closing for now. Any body running into this in the future, or having a strong argument that it should be changed, feel free to reopen :)
Most helpful comment
The fix for my problem was actually somewhere else; the value should never have become NaN in the first place; but the infinite loop was unexpected ;)
Well, to be fair this is how it works in any language that follows the IEEE standard; e.g. https://github.com/dmlloyd/openjdk/blob/jdk9/jdk9/jdk/src/java.base/share/classes/java/lang/Double.java#L550