Click here to Skip to main content
16,022,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using React 18, Typescript, NextJS 14, next-auth v5 ... In a client component, I get the user (session.data.user). Then I try to get that user from the home page. But, what I get the the previous user (or no user if the person wasn’t signed in). In order to get the user I must do a browser refresh. An example of this, I want to show the signed in username on the home screen ... I must do a manual browser refresh before the logged in user is available ... this is obviously not acceptable. I’m been trying multiple different things over the last 2 weeks with no success. Can anyone help? Here is an example of my code ...

  ```{!user ? (
            <QuestionSection
               questionData={sampleQuestions}
               fireworksIndex={3}
            />
         ) : (
            <QuestionSection
               questionData={questions}
               fireworksIndex={63}
            />
         )}'''
     
     In this case, the data is loaded correctly but a refresh is necessary to make it available.  Help.  


What I have tried:

useEffect, putting data in localstorage or sessionStorage (can read it back with no problem but still need to do a manual refresh to get the new data to display) ... I've forgotten everything I've tried over the last couple of weeks.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900