Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!