-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#356 / #330 Bug: reduce page load times & look into useCallback #363
base: develop
Are you sure you want to change the base?
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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment, but we also need a unit test to test when the code calls getUser().
app/league/all/page.tsx
Outdated
@@ -18,6 +19,11 @@ const Leagues = (): JSX.Element => { | |||
const [leagues, setLeagues] = useState<ILeague[]>([]); | |||
const [currentWeek, setCurrentWeek] = useState<IGameWeek['week']>(1); | |||
const { user } = useDataStore((state) => state); | |||
const { getUser } = useAuthContext(); | |||
|
|||
if (!user.id || user.id === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go into the AuthContextProvider. Otherwise, every page will need this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Done.
@@ -42,10 +42,6 @@ const Leagues = (): JSX.Element => { | |||
}; | |||
|
|||
useEffect(() => { | |||
if (!user.id || user.id === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
*/ | ||
const getUser = useCallback(async () => { | ||
const getUser = async (): Promise<void | IUser> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need unit tests for this file. I do not see a test file at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
useCallback
hook forgetUser()
inAuthContextProvider
and found that it was not requiredSCREENSHOT
VIDEO
CleanShot.2024-07-02.at.14.14.37-converted.mp4