#356 / #330 Bug: reduce page load times & look into useCallback#363
#356 / #330 Bug: reduce page load times & look into useCallback#363chris-nowicki wants to merge 6 commits intodevelopfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Gridiron Survivor Application
Project name: Gridiron Survivor Application
Only deployments on the production branch are activated automatically. If you'd like to activate this deployment, navigate to your deployments. Learn more about Appwrite Function deployments.
|
shashilo
left a comment
There was a problem hiding this comment.
Added a comment, but we also need a unit test to test when the code calls getUser().
| const { user } = useDataStore((state) => state); | ||
| const { getUser } = useAuthContext(); | ||
|
|
||
| if (!user.id || user.id === '') { |
There was a problem hiding this comment.
This should go into the AuthContextProvider. Otherwise, every page will need this code.
| }; | ||
|
|
||
| useEffect(() => { | ||
| if (!user.id || user.id === '') { |
There was a problem hiding this comment.
This entire empty user will be fixed with this change? I had to add it to 2 other pages because that's how it works for now.
There was a problem hiding this comment.
@shashilo I am confused. need more info. I fixed this to remove it from page.tsx and moved that into the useEffect of authContextProvider as that is the only place I could get it to work and the provider wraps around all pages.
| * @returns {Promise<void | IUser>} - The user data or an error. | ||
| */ | ||
| const getUser = useCallback(async () => { | ||
| const getUser = async (): Promise<void | IUser> => { |
There was a problem hiding this comment.
We will need unit tests for this file. I do not see a test file at all.
There was a problem hiding this comment.
roger that. I will add one.
|
@chris-nowicki You'll have to review this again. This is still rendering multiple times because of the way your context is set up. LMK when you have time, I'll show you how to debug this. |

fixes #330 and #356
useCallbackhook forgetUser()inAuthContextProviderand found that it was not requiredSCREENSHOT
VIDEO
CleanShot.2024-07-02.at.14.14.37-converted.mp4