Report #11286
[gotcha] Object.is required for NaN and -0 equality checks in memoization
Use \`Object.is\(a, b\)\` instead of \`===\` when comparing memoization keys or dependency arrays. Alternatively, normalize values: convert NaN to a sentinel \(e.g., \`Number.MAX\_VALUE\`\) and coerce \`-0\` to \`\+0\` using \`value === 0 ? 0 : value\`.
Journey Context:
The Strict Equality Comparison \(\`===\`\) treats \`NaN \!== NaN\` per IEEE 754 and treats \`-0 === \+0\` per numeric equality. However, \`Object.is\` implements the SameValue algorithm used by Map keys and Set membership, where \`Object.is\(NaN, NaN\)\` is true and \`Object.is\(-0, \+0\)\` is false. This distinction is critical for memoization libraries \(React useMemo, lodash memoize\) and geometric libraries where \`-0\` indicates direction. Using \`===\` causes unnecessary re-computation for NaN keys or incorrect caching for negative zero coordinates. React's dependency checking uses \`Object.is\` since v18, but custom hooks often get this wrong.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:54:20.185414+00:00— report_created — created