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

75
Views
React Component not re-rendering when prop changes

I have three components - layout, navigation, and room dropdown. Layout gets a property 'lobbyCode' from a database and sets it to a state, then passes it as a prop to Navigation. Navigation then passes this prop as a prop to RoomDropdown, however the room dropdown component does not re-render when the lobbyCode state is changed in layout. Navigation seems to handle the state change fine and re-renders correctly, so I'm not sure what's happening.

Layout:

const { user, isAuthenticated, isLoading } = useAuth0();
const [lobbyCode, setLobbyCode] = useState("");

return (
    <div>
       <Navigation GetUser={GetUser} GetPlayers={GetPlayers} lobbyCode={lobbyCode} user={user} 
       isAuthenticated={isAuthenticated} isLoading={isLoading} />
    </div>
  )

useEffect(() => {
    if (isAuthenticated) {
      GetUser(user.email).then(result => {
        if (result.length > 0) {
          setLobbyCode(result[0].lobby);
        }
      });
    }
  }, [user]);

Navigation:

<RoomDropdown lobbyCode={props.lobbyCode} GetUser={props.GetUser} GetPlayers={props.GetPlayers} user={props.user} />

RoomDropdown

useEffect(() => {
    console.log(props.lobbyCode);
}, [props.lobbyCode]);

The result is that the room dropdown will just print undefined and never update, even once the lobby code is loaded.

about 4 years ago · Santiago Gelvez
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!