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.

Why doesn’t Recoil manage the unique key in atom and selector

See original GitHub issue

I don’t see that the user needs to use the defined key anywhere. So why does he/she needs to create it manually ?

const textState = atom({
  key: 'textState', // this is used nowhere, why not just abstract it out?
  default: '', 
});

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:21
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

20reactions
dkovacevic15commented, Jun 24, 2020

See #32 (comment)

Having a string key is necessary to provide a fixture for state which survives past the lifetime of the app – it enables scenarios such as debugging for dev tools, and stable persistence.

A question some of our team members are curious about: how burdensome is it to add keys?

My team is looking into adopting Recoil for a project, but since we expect the project to grow and stay around for a long time, we’re very concerned about key collisions happening. It seems like a landmine whose surface area gets bigger and bigger the more you work on an app. Maybe generate a key internally as a fallback, but have tutorials and documentation strongly encourage adding an optional name value to the atom definition?

13reactions
uptonkingcommented, Jul 6, 2020

naming is really hard.
since key can be generated automatically using tools like uuidv4(), I want Recoil to handle the task for me.
Human is unreliable, easy to make names conflict.
please save me from naming.

Read more comments on GitHub >

github_iconTop Results From Across the Web

selector(options) - Recoil
Recoil manages atom and selector state changes to know when to notify components ... key - A unique string used to identify the...
Read more >
Lessons learned from moving to Recoil.js - Kitemaker blog
This is because selectors are not updated as the individual operations of a transaction are applied to the recoil state, so the data...
Read more >
Multiple form values in one react recoil atom override each other
However, the idiomatic way to do this (and where Recoil becomes more powerful) is composition of atom s using a selector , which...
Read more >
Top 6 React state management libraries for 2022
The core concepts to understand in Recoil are atoms and selectors. ... In contrast, Jotai doesn't require keys and depends entirely upon ......
Read more >
Jotai vs. Recoil: What are the differences? - LogRocket Blog
This article compares the state management libraries to help you ... In fact, Jotai atom is used to implement both atom and selector...
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