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

240
Views
React hook using useEffect updates on web browser but not on mobile browser

This code works on my desktop browser but not on my mobile browser (Safari or Chrome).

const Board = () => {
    const x=useRecoilValue(nstate);
    const values=useRecoilValue(nspaces);
    const [hash,setHash]=useRecoilState(nplaces);
    const size=Math.sqrt(values.length);
    let bx=Array.from({ length: Math.ceil(values.length / size) }, (v, i) => values.slice(i * size, i * size + size));
    let board=bx.map((item)=> <Fleg>{item.map((x)=> <Col><p><img src={getPhoto(hash[x])} alt=""/></p><p>{Ops(hash,setHash,x)}</p></Col>)}</Fleg>);
    useEffect(() => {
            console.log("show the hash: ",hash);
            board=bx.map((item)=>
                    <Fleg>{item.map((x)=> <Col><p><img src={getPhoto(hash[x])} alt=""/></p><p>{Ops(hash,setHash,x)}</p></Col>)}</Fleg>
            );
    },
    [hash]
    );

    return (
            <>
            {board}
            </>
    );
}

The "hash" is just a dictionary object that has like [0,0]: 1, for all the possible values/positions of the 'board' ( (0,0) through (3,3) ).

If the value is 1, getPhoto(hash[x]) shows a red dot, if 2 a blue dot.

The problem, which only happens on mobile, is that when hash updates, the surrounding 'squares' get updated images, but the current 'square' is not updated.

To me it seems like it should work - hash is being updated, and printing to the console w/the expected values - but the UI doesn't show what hash does. The current 'cell' does not update its image, even after it has changed.

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!