-
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
Replace redux code by context API #79
Conversation
Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-river-017c6bf1e-79.westus2.azurestaticapps.net |
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.
I've gone through the codes and I will test it tmr.
Nice work! Don't forget to get enough sleep 😪
<CourseSearchingProvider> | ||
<CourseTableProvider> | ||
<UserDataProvider> | ||
<DisplayTagsProvider> | ||
<Box w="100vw" h={{ base: "100%", lg: "" }}> | ||
<HeaderBar useColorModeValue={useColorModeValue} /> | ||
{content(props.route)} | ||
<Footer /> | ||
</Box> | ||
</DisplayTagsProvider> | ||
</UserDataProvider> | ||
</CourseTableProvider> | ||
</CourseSearchingProvider> |
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.
Since we've gotten rid of redux, there will be more context providers in the future.
To prevent pyramid of doom, I suggest we can solve this based on one of the solutions here.
but ignore this comment, LOL
This is what Redux solves. – coreyward Jul 24, 2018 at 17:33
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.
tested without issues.
Run e2e tests manually ( feel free to add any item which should be checked ):
https://www.notion.so/jchiroto/E2E-Test-RunBook-16001fb1d7cc4674b2e3b81e3ae24719
/queries
files, and move global states setters out of those fetchers for better reusability and better compatibility if we want to adopt frameworks likeSWR
.Also remove
try...catch...
block in fetchers:useSWR
hook in future, it already has stuffs likeisError
&onError
callback in syntax like thisFor Hover Course Feature, I found using Context API can't fully replace Redux "performance-wisely" because if there are any states changes in Context Provider, it will force re-render to whole sub-tree and the client become so laggy (discussion 1, discussion 2) (Redux doesn't because it utilize
useSelector
and it will only re-render component using this hook). So I think if the set states operation happen frequently and the computation is expensive like our hover feature, it's not good to replace redux by context API. So I found a light-weighted library calledValtio
(article), it also provide render-optimized feature like redux, and the performance looks good.Also unify global states' name to
camelCase
instead ofsnake_naming_case