setting an atom with a promise results in `deleting atomState with read promise` error
See original GitHub issueI put together an example here:
https://github.com/zcaudate/js-blessed.store-test
but basically I’m getting an error when using atoms with Suspense.
I’d like to be able to have an atom that is initialised with nil, can have a promise resolving to some data and then be reset back to nil.
So in the example, the atom’s initial value is null
. createRecord is basically create atom
with some metadata stuffed into it:
Then I set the atom’s value to a promise (which resolves after a time out) and it produces this error in the suspense element:
// React will try to recreate this component tree from scratch using the error boundary you provided, Debug.
[Bug] deleting atomState with read promise {
toString: [Function: toString],
init: null,
read: [Function (anonymous)],
write: [Function (anonymous)],
id: 'js-blessed.store-test.main/UserData',
section: 'js-blessed.store-test.main/User'
}
This is a bug or a feature of atoms in jotai and if it’s a feature, how do I implement a resettable atom with a promise?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Error handling with promises - The Modern JavaScript Tutorial
Promise chains are great at error handling. When a promise rejects, the control jumps to the closest rejection handler.
Read more >Asynchronous Data Queries - Recoil
Simply return a Promise to a value instead of the value itself from a ... with synchronous atom state, derived selector state, or...
Read more >React + Recoil - Set atom state after async HTTP GET or ...
This is a quick example of how to set the state of a Recoil atom after sending an async HTTP GET or POST...
Read more >Simplifying your application state management with Recoil
A hook that returns the current atom or selector value. This hook is intended to use when you only need to read the...
Read more >TanStack Query - Jotai
The second one is called statusAtom and it's an atom for the full result from ... A query can be used with any...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks for your help!
okay. this actually works on the dom:
https://codesandbox.io/s/react-typescript-forked-813p1?file=/src/App.tsx
It must be an issue with the react-blessed renderer.