Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
How to update Recoil JS Atom Object

I have an Atom object defined like this:

export const walletInfo = atom({
  key: "walletInfo",
  default: {
    connected: false,
    someString: "",
    someInt: 0,
    someOtherInfo: "",
  },
});

The question is, how do I change only single value in Atom object without overwriting everything else? For example, how do I set connected: true and keep the rest of the information?

The code below will "erase" the rest of the object

import { walletInfo } from "../src/atoms";
const [wallet, setWallet] = useRecoilState(walletInfo);

setWallet({
   connected: true,
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to combine the previous state and updated state like this

setWallet((prevState) => ({
   ...prevState,
   connected: true,
}));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda