If value is a NaN, it causes an infinity render
Author: bhbsCreated Dec 30, 2023Updated Mar 18, 2024
same as #2280
React version: v18.2.0
Reproduction
https://github.com/bhbs/recoil-repro-2298
import { atom, useRecoilValue } from "recoil";
const Atom = atom({
key: "someKey",
default: NaN,
});
function App() {
const recoilValue = useRecoilValue(Atom);
return <div>{String(recoilValue)}</div>;
}
export default App;Current behavior
Expected behavior
Rendered successfully
How to fix
State should be compared using Object.is
should be
return (
// $FlowFixMe[prop-missing]
other.state === this.state && Object.is(other.contents, this.contents)
);Note
Problems in similar situations
Source: facebookexperimental/Recoil