question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useResetAtom does not work on atomWithDefault

See original GitHub issue

atomWithDefault can be reset by sending the REFRESH symbol. atomWithReset can be reset by sending the RESET symbol or with useResetAtom.

useResetAtom does not work on atomWithDefault.

Should we get rid of the REFRESH symbol, and instead use the RESET symbol everywhere including atomWithDefault? Then useResetAtom would work on atomWithDefault.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dai-shicommented, Jun 23, 2021

API-wise, it’s possible. However, implementation-wise, atomWithReset is only one atom internally, whereas atomWithDefault comes with two atoms. In other words, atomWtihReset can be more performance tuned.

0reactions
dai-shicommented, Jun 23, 2021

Thanks for the comment. Just opened a PR #552.

Read more comments on GitHub >

github_iconTop Results From Across the Web

atomWithDefault - Jotai
Usage. This is a function to create a resettable primitive atom. Its default value can be specified with a read function instead of...
Read more >
jotai/atom-with-default.mdx at main - GitHub
This is a function to create a resettable primitive atom. Its default value can ... import { useAtom } from 'jotai' import {...
Read more >
@fattafatta/rescript-jotai - npm
A hook that returns only the update function of an atom. Can be used to access writeOnly atoms. let atom = Jotai.Atom.
Read more >
docs/api/utils.mdx | jotai@v1.5.0 - Deno
utils/atom-with-reducer.mdx) This is a function to create an atom with an embeded reducer function to update the value.10. [atomWithDefault](.
Read more >
jotai - UNPKG
7, throw new Error('Dynamic require of "' + x + '" is not supported');. 8, };. 9, const WRITE_ATOM = "w"; ... 34,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found