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

170
Vistas
How to inspect a value and re-render when the value is changed in ReactJS hook?

I have two value to inspect and display to my page: connected(boolean) and publicKey(PublicKey). If the value of any one is changed, re-render the component and displayed the changed value on the page.

Currently my code is as below, it won't show the changes even the value was updated. What should I do?

import { useWallet } from "@solana/wallet-adapter-react";
import { useEffect } from "react";

export default function TestComponent() {
    const { connected, publicKey } = useWallet();

    return (
        <div>
            <h2>Is Connect?: {connected}</h2>
            <h2>Public Key: {publicKey?.toString}</h2>
        </div>
    )
}

And the source code of useWallet() is about:

export interface WalletContextState extends WalletAdapterProps {
    wallets: Wallet[];
    autoConnect: boolean;
    wallet: Wallet | null;
}

export interface WalletAdapterProps {
    publicKey: PublicKey | null;
    connected: boolean;
}

export const WalletContext = createContext<WalletContextState>({} as WalletContextState);

export function useWallet(): WalletContextState {
    return useContext(WalletContext);
}
about 4 years ago · Juan Pablo Isaza
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