Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final steps in the react-router v6 migration! 馃帀 #4377

Merged

Conversation

ivarnakken
Copy link
Member

@ivarnakken ivarnakken commented Dec 25, 2023

Description

Remove redux-first-history

It is not compatible with react-router v6.4, and is not something we
"really" need.


Remove compatabillity package and bump react-router to v6

All uses of useHistory had to be replaced with useNavigate.


Fix ssr routing with context

react-router v6 does not allow context to be passed as a prop to
StaticRouter, so a simple workaround was to just create our own React
Context.


Make lego-bricks compatible with webapp's upgraded router

Also remove a bunch of stub https://github.com/types packages. Some are already provided in
the packages themselves, and the react-router specific ones caused some
compatabillity issues for some reason.

And fix a small ts error in the ConfirmModal code preventing build to complete.

Testing

  • I have thoroughly tested my changes.

SSR seams to work completely fine. Tried to visit most routes, no problems.

However, I did notice some problems with building on node 16, so we ought to bump that very soon.

@ivarnakken ivarnakken added types Pull requests that improve or fix types dependencies Pull requests that update a dependency file review-needed Pull requests that need review bug-fix Pull requests that fix a bug technical-debt Pull requests that reduces technical debt lego-bricks Pull requests related to lego-bricks labels Dec 25, 2023
@ivarnakken ivarnakken requested a review from a team December 25, 2023 05:43
@ivarnakken ivarnakken self-assigned this Dec 25, 2023
@ivarnakken ivarnakken changed the title Final steps in the react router v6 migration! 馃帀 Final steps in the react-router v6 migration! 馃帀 Dec 25, 2023
@ivarnakken ivarnakken force-pushed the further-steps-in-react-router-v6-migration branch from 67884c2 to 643802d Compare December 25, 2023 10:02
@ivarnakken ivarnakken force-pushed the further-steps-in-react-router-v6-migration branch from 643802d to cddcd9d Compare December 25, 2023 10:46
It is not compatible with `react-router` v6.4, and is not something we
"really" need.
@falbru
Copy link
Contributor

falbru commented Dec 25, 2023

Great job 馃コ I'll try to review your code, although that's quite a daunting task 馃槄 I'll, at the very least, run the code and test if everything works alright :))

All uses of `useHistory` had to be replaced with `useNavigate`.
`react-router` v6 does not allow context to be passed as a prop to
`StaticRouter`, so a simple workaround was to just create our own React
Context.
Also remove a bunch of stub @types packages. Some are already provided in
the packages themselves, and the `react-router` specific ones caused some
compatability issues for some reason.

And fix a small ts error in the ConfirmModal code preventing build to complete.
Copy link
Contributor

@falbru falbru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 馃敟

@ivarnakken
Copy link
Member Author

This migration actually removes 305 ts errors!

I've noticed several issues with running `react-router` v6 on `node`
v16. It was about time anyways ..

For some reason I now had to update some stylelint stuff?
The tests relied on passing props into the page components, but this is
no longer accepted. Nevertheless, what they try to test is already
tested in our e2e tests, and besides it's quite uncommon to unit test entire
pages.
@ivarnakken ivarnakken force-pushed the finish-react-router-migration branch from deaf593 to 9d73130 Compare January 9, 2024 10:45
@ivarnakken ivarnakken requested a review from a team January 9, 2024 11:12
Copy link
Member

@norbye norbye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff! Haven't run it to test it, but I've looked through all of the code changes and they look nice 馃挴

app/actions/UserActions.ts Show resolved Hide resolved
@ivarnakken ivarnakken force-pushed the finish-react-router-migration branch 2 times, most recently from 3b183b1 to 314a592 Compare January 9, 2024 20:50
@ivarnakken
Copy link
Member Author

We're finally passing CI! I never thought this day would come when I started this migration back in August hehe

@ivarnakken ivarnakken added the approved Pull requests that have been approved label Jan 10, 2024
@ivarnakken
Copy link
Member Author

@haukkagu @norbye Made some few additions that you may want to look over 馃槃

Copy link
Member

@norbye norbye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice stuff(:

app/routes/contact/components/ContactForm.tsx Outdated Show resolved Hide resolved
app/routes/events/components/EventEditor/index.tsx Outdated Show resolved Hide resolved
app/components/NavigationTab/NavigationLink.tsx Outdated Show resolved Hide resolved
* Issues with a default pool not appearing when picking an appropriate
  event status type
* Pool merge time was being validated when it was not supposed to
* useMazemap would always be true, even when a normal location had been
  set
* Not actually in the editor, but it was previously not possible to view
  registrations on the event detail page because of the wrong check for
  `hasFullAccess`
* Better (and accurate) validation
Among other things, `SubmitButton` now accepts a `disabled` prop in case you
want to check for more things.
When the user had no prior meetings, `meetingSections.length` would
always be `0`, leading to an endless loop of fetching. Fixed by
introducing a simple flag.
Not sure why `pagination` was added to the dependency array, but
nevertheless this caused an endless loop of fetching.

The "fetch more" button seemed to not work without some proper feedback,
so I added that as well.
The query should be in the dependency array to force a fetch when
switching the page (the query).
Extend the NavLink wrapper to accept a list of paths to "accept".
I believe the core of the issue was the spread operator for the query in
the fetch action, but I'm too tired to look into exactly why that was.
All fields were disabled when creating a new restricted mail
because the `isNew` check was wrong. Unlike for the forms
for email lists and users, the url param here will not be `new`
but rather `undefined`.
`endpoint` would be `undefined`, and a bad API request would be made.
Base automatically changed from further-steps-in-react-router-v6-migration to migrate-away-from-connected-router January 11, 2024 11:42
@ivarnakken ivarnakken merged commit 7656be4 into migrate-away-from-connected-router Jan 11, 2024
4 checks passed
@ivarnakken ivarnakken deleted the finish-react-router-migration branch January 11, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Pull requests that have been approved bug-fix Pull requests that fix a bug dependencies Pull requests that update a dependency file lego-bricks Pull requests related to lego-bricks review-needed Pull requests that need review technical-debt Pull requests that reduces technical debt types Pull requests that improve or fix types
Projects
None yet
3 participants