-
Notifications
You must be signed in to change notification settings - Fork 5
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
Organizer Refactor - New useSWR hooks and abstraction #360
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…date as well will have to investigate in future
Was looking to update the "swr" package to >v2.0.0 because it supports an "isLoading" flag however the "next-auth" package current version (which is also old) relies on the properties of "swr" v1.3.0. Therefore I am unable to update either. I have a work around in to simulate loading (null data check) but it is not a true "loading" flag. |
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.
Just a couple tiny changes. Great work!!!!
LGTM. Probably the cleanest refactor I've ever seen. Proud of yall @lisaliuu @jacoblurie29 🔥 |
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.
Nice work @lisaliuu @jacoblurie29 !!
Our codebase is now so much more readable 🥲
Organizer Refactor PR
This PR abstracts each tab of the organizer into its own file and creates a new reusable react hook to handle the useSWR function.
useCustomSWR
In
request-utils.ts
the following function is defined. It simplifies the use of the useSWR function by taking the url, request type, and error message as input params and a generic typeT
. The typeT
is the interface for the returned data.Example of useCustomSWR:
This can be used to replace any useSWR hook as it will simplify code, remove redundancy, and shorten the length of many files.
Refactoring
The
Organizer.tsx
file was refactored to abstract all of the tabs into individual components. Those components now load their own data as opposed to the web page loading the data and passing the data down through the props.Much of the null checks, loading, and errors are combined to simplify the logic of the UI in statements like this:
This allows the tabs to be generically formatted as so: