-
Notifications
You must be signed in to change notification settings - Fork 0
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
upgrade to react@19 #106
base: dev
Are you sure you want to change the base?
upgrade to react@19 #106
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Small thing: MUI Joy v5 is not fully compatible w/ React 19. Specifically, it seems the Autocomplete component does not follow React 19 rules, so you'll see this error: Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release. You can reproduce this by changing your major to something else (you'll get an error in dev mode). It does not crash the app in dev nor in build. To emphasize, this is an issue with MUI Joy, not us. Unfortunately, its development is currently on hold. Their last update was five months ago. We can either:
|
On a related note, React 19 brought along some deprecations. One such deprecation is that You can see how we would refactor it here. Not a pressing issue, but it's something we'll have to address at some point down the line. Plus, it'll be a good exercise for us to understand what these refs are actually doing. Most of the affected components were imported from external libraries but designed to be modified by the user. |
References
Changes
Short version: Instead of reloading the entire dashboard page to updated user settings, we now only re-render the necessary components that changed, e.g. semester bin labels, tabbed menu labels, and recursive dropdowns.
Long version: Before, we would reload the entire page (and thus the entire DOM tree) to force re-render components dependent on the user settings component. This was because Canvas.tsx did not have access to UserSettings/SettingsModal since that component was in the Navbar component.
Now, we use a Zustand store to keep track of academicPlan and the updateRequirements function in the user slice. This allows all components throughout the app to access a singular source of truth, namely whatever data is currently available in the user slice.
Since academicPlan is tracked by the store, it refreshes without needing to re-render Canvas. TabbedMenu takes in academicPlan as a prop; therefore, TabbedMenu and all of its children will re-render each time academicPlan changes, which occurs when the user changes their major, class year, etc.
Note: It still takes some time to fetch the updated data, so there is still a small delay between saving the user settings and the new settings being rendered. Nonetheless, the rendering logic for Canvas and its components is now a bit tidier and more "proper" in the sense that we no longer redundantly force re-render the entire DOM tree.