Questions tagged [recoiljs]

A state management library for React.

Recoil is a minimal library that provides an experimental set of utilities for state management with React.

  • Minimal and Reactish: Recoil works and thinks like React. Add some to your app and get fast and flexible shared state.
  • Data-Flow Graph: Derived data and asynchronous queries are tamed with pure functions and efficient subscriptions.
  • Cross-App Observation: Implement persistence, routing, time-travel debugging, or undo by observing all state changes across your app, without impairing code-splitting.

Recoil lets you create a data-flow graph that flows from atoms (shared state) through selectors (pure functions) and down into your React components. Atoms are units of state that components can subscribe to. Selectors transform this state either synchronously or asynchronously.


Useful links


Related tags


Reference

268 questions
0
votes
1 answer

Recoil DarkMosw

i have a question about recoil. In my app a have few screens. There are a lot of Text Components. I am doing dark mode now and i try to use recoil for this. I have atom isDarkMode, which can be false or true. There is a problem. Is needed to check…
0
votes
1 answer

How can I implement interdependent state in Recoil?

I'm having trouble figuring out how to make a number of Recoil atoms state's interdependent. For example, (this is not my use case, but it's a simple demonstration of the concept I'm having trouble with), imagine a radio button group where the state…
SnippyDippy
  • 83
  • 1
  • 6
0
votes
1 answer

React Native Invalid hook call when using useRecoilValue

I got an error Invalid hook call when I am using useRecoilValue. Am I wrong to use this hooks? then how can I solve this problem? List.fn.js import { Alert, AsyncStorage } from "react-native"; import { useRecoilValue } from "recoil"; import {…
bash.ruv
  • 25
  • 1
  • 1
  • 4
0
votes
1 answer

Two recoil react tests conflicting based off of rendered value

I have a single atom that stores an object with authToken and username strings. If authToken is present, I want to present protected content. If not, I want to redirect the user to the login page. Tests: Does not populate the "authToken" and we…
0
votes
1 answer

react native and recoil multiple re-renders of RecoilRoot

I have these components without any recoil's hooks. const C = () => { console.log('---->C') return C } const B = () => { console.log('--->B') return <> B } const A = () => { console.log('-->A') …
adrian oviedo
  • 684
  • 1
  • 8
  • 27
0
votes
3 answers

React input field does now work when typing too fast

I have this simple component that checks if username is valid. It does so by querying firebase when the input value changes. There is one problem with it. When I am typing too fast into the input field, the value in it just doesn't have enough time…
user14884204
0
votes
1 answer

What is the pattern for ensuring a user action triggers a Recoil state update in a Jest test

Suppose I have a (rather contrived) controller and view const useController = () => { const setId = useSetRecoilState(idState) return { setId } } const MyComponent = () => { const { setId } = useController() return (
user1713450
  • 1,307
  • 7
  • 18
0
votes
2 answers

Subscriber pattern with RecoilJS (React)

I am building an app with React, TS, Mapbox, react-mapbox-gl and RecoilJS. This is the Dashboard component in which I'm working: import React from "react"; import PageTemplate from "../../components/PageTemplate/PageTemplate"; import ReactMapboxGl…
0
votes
1 answer

How can i get multiple recoil atoms when using components multiple?

In some components i am using recoil atoms to manage my states. One example is my modal component. It look something like this: export const modalState = atom({ key: "modalState", default: false }) export const useToggleModalState = () => { …
Niklas
  • 1,638
  • 4
  • 19
  • 48
0
votes
1 answer

Batch set state for Recoil

If I have to set states from multiple different atoms as part of some high level action user is taking, I want all subscribing components for any of the impacted atoms to be re-rendered only once when the entire states are set as a batch. Is this…
jiminssy
  • 2,149
  • 6
  • 28
  • 45
0
votes
0 answers

Do you know how to keep updates for the value of useContext even after reloading?

After updating useState defined in useContext of react with a child component, is there a way to retain the value (holds the updated value) even if it transitions to another page and reloads? UseState "initial value" called A defined in…
dksq
  • 3
  • 2
0
votes
1 answer

Event Emitter Pattern for RecoilJS

Is there a pattern or technique we can use for handling events in Recoil? In Saga we could use the emit method and create stream of data. Ive been trying to wrap my mind around how something like this can be achieved in Recoil. For ex scanning for…
Sten Muchow
  • 6,623
  • 4
  • 36
  • 46
0
votes
1 answer

How to update a React/Recoil state array from web bluetooth subscription callbacks?

I am new to using React and Recoil and want to display real-time charts (using D3) from data that is gathered in real-time using the Web Bluetooth API. In a nutshell, after calling await myCharacteristic.startNotifications() and…
DurandA
  • 1,095
  • 1
  • 17
  • 35
0
votes
2 answers

Easier way to set React or Recoil state objects with array properties

Hope someone can help me with an easier way of updating my recoil states on more complex objects/arrays. I'm mainly a C# developer, but trying to learn some decent ways of coding javascript. This just seems to ugly and overcomplicated, the way my…
0
votes
1 answer

React useRecoilState (Recoil) - Does it subscribe/render even if the state isn't used when only needing the accessor?

Sometimes, we only need to use the accessor/mutator of a shared state (e.g: setBlockPickerMenu). const [blockPickerMenu, setBlockPickerMenu] = useRecoilState(blockPickerMenuState); ... setBlockPickerMenu(null) And we don't need the value itself…
Vadorequest
  • 16,593
  • 24
  • 118
  • 215
1 2 3
17
18