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.

[Question] Where do atoms and derived atoms values 'live'?

See original GitHub issue

Hi @dai-shi, first of all thank you for this library. It is great to have different options, approaches and improvements around the React state topic. Good job!

I’m playing a bit with it and trying to better understand what’s happening under the hood, which use cases can be easily covered with jotai and which doesn’t (if any). And several questions arised. I didn’t check code yet, sorry, so my questions are based on guessing.

My first assumption when I saw the Provider wrapping the tree:

<Provider>
  <App />
</Provider>

and also based on this quote:

If you need React Context alternatives, Jotai comes with enough features

was to think that:

  • Provider is kind of a contextual store where all the atom values live. Is that correct?

Also, for learning/debug purposes:

  • Is there a way we can check atom values directly from its “store” without consuming them? Similar to what Redux DevTools offer.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
fjcalzadocommented, Oct 6, 2020

So your proposal is to add autoclean flag in Provider, and if it’s false, we don’t garbage collect. If not specified, the default is the current behavior (= garbage collected.)

Exactly, that was one of the proposal. The other one was to being able to assign atoms to a certain Provider, so you can completely mimick React Context and place Providers wherever you want along with its atoms.

but I wonder if developers can effectively use it

It can be harsh to understand and use it, I agree. It is a trade off, the more flexibility you offer, the more powerful the library would be. The less flexibility the easier to use although with limitations.

I am just trying to think what would happen with typical scenarios and check if jotai suits my needs. That’s what I am suggesting all this ideas. It doesn’t have to be like that, of course. I just find useful this kind of debate to be aware of possible limitations and solutions

0reactions
dai-shicommented, Sep 9, 2021

Note that #640 changed the scope api a bit differently. (the internal is the same.) You are welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Matter, elements, and atoms | Chemistry of life (article)
The protons (positive charge) and neutrons (neutral charge) are found together in the tiny nucleus at the center of the atom. The electrons...
Read more >
Atoms and Elements | Biology for Majors I
Atoms are made up of protons and neutrons located within the nucleus, with electrons in orbitals surrounding the nucleus. Protons and neutrons have ......
Read more >
Atoms, Molecules, and Ions
In the fifth century BC, Leucippus and Democritus argued that all matter was composed of small, finite particles that they called atomos, a...
Read more >
Atom | Definition, Structure, History, Examples, Diagram, & Facts
atom, smallest unit into which matter can be divided without the release of electrically charged particles. It also is the smallest unit of...
Read more >
What is an atom? Definition and Structure
Protons and neutrons are subatomic particles that make up the center of the atom, or its atomic nucleus. A proton is positively charged....
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