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.

Can an atom's value be changed from a non-react environment?

See original GitHub issue

Recently I came across the use case like a pure js file Realtime.service.js is making a connection with the WebSocket server and streaming realtime data to UI (need to feed multiple React’s components with a chunk of data coming from realtime WS).

Now if Recoil’s atom state can be changed directly from Realtime.service.js (which is not a React component but js service) with realtime steam then all the components connected with the relative atoms will be updated on realtime data streaming.

Is that a valid use case? Right now I’ve seen that Atom’s state only get/set default-value by React’s hook.

In redux it is possible, we can update the store from any js file (non-react env). and the react-redux bridge auto handles the changes to connected components. Now we’re moving from Redux to Recoil, we’re having this roadblock.

Issue Analytics

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

github_iconTop GitHub Comments

15reactions
ajoslincommented, Sep 2, 2020

You could hack it

function MyCmp () {
  const setValue = window.setValue = useSetRecoilState(someState)
}

function somewhereElse () {
  window.setValue(123)
}
4reactions
drarmstrcommented, Sep 3, 2020

I’m hopeful that this API #380 could help with this use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can the decay half-life of a radioactive material be changed?
Yes, the decay half-life of a radioactive material can be changed. Radioactive decay happens when an unstable atomic nucleus spontaneously ...
Read more >
Energy transition from molecules to atoms and photons
When renewable energy becomes cheaper than coal and oil, the climate change deniers can have no excuse resist the renewable energy transition.
Read more >
Relating atomic energy, radius and electronegativity through ...
1 shows how trends in the changes of radii and electronegativity can be opposite in a relative comparison between atoms.
Read more >
The Difference a Single Atom Can Make: Synthesis and ...
It is likely that the work of ours that is most easily recognized as arising from single heavy atom changes or exchanges is...
Read more >
Non‐Bonded Radii of the Atoms Under Compression - 2020
Atomic radii can also be useful in quick predictions of molecular ... atom compression by a homogeneous and non-reactive neon environment.
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