Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a selector return a NaN, it cause a infinity render problem #2280

Closed
lordGuan opened this issue Aug 29, 2023 · 1 comment
Closed

If a selector return a NaN, it cause a infinity render problem #2280

lordGuan opened this issue Aug 29, 2023 · 1 comment

Comments

@lordGuan
Copy link

lordGuan commented Aug 29, 2023

import "./styles.css";
import { selector, useRecoilValue, RecoilRoot } from "recoil";

const A = selector({
  key: "xxx",
  get() {
    return NaN;
  }
});

function R() {
  const v = useRecoilValue(A);
  return <div>{v}</div>;
}

export default function App() {
  return (
    <RecoilRoot>
      <div className="App">
        <h1>Hello CodeSandbox</h1>
        <h2>Start editing to see some magic happen!</h2>
        <R />
      </div>
    </RecoilRoot>
  );
}

react:18.2.0
recoil:0.7.7

Demo:https://codesandbox.io/s/young-tree-r42qyj?file=/src/App.js:0-463

But [email protected] with [email protected] is fine!

It seems related to useSyncExternalStore api...

@lordGuan
Copy link
Author

I just disabled the 'recoil_sync_external_store' GK by

RecoilEnv.RECOIL_GKS_ENABLED.delete("recoil_sync_external_store")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant