-
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
HPC-9965 Upgrade react-router-dom
to react-router
v7.0.2
#480
base: develop
Are you sure you want to change the base?
Conversation
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.
Checks have passed and this pull request is ready for manual review
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.
Let's also migrate CDM to use RouterProvider
from v7. We're in a monorepo, which allows easier sharing of code & libraries, so let's not create a divide, since refactoring isn't too hard in this case.
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.
Checks have passed and this pull request is ready for manual review
https://reactrouter.com/upgrading/v6 no use of relative paths, `React.lazy` or `RouterProvide`, no changes needed
It was necessary to modify the dependency array of async-autocomplete-field for it to work
`react-router-dom` is no longer necessary, we can just import `react-router` for a more simplified package
This is a necessary step to being able to resolve import from `react-router/dom`
https://reactrouter.com/6.28.0/components/routes#routes In `hpc-cdm` there are many `<Routes />` elements, for the way is built it makes sense to let these `<Routes />` where they are instead of briging all of them to `main.tsx` since we have logic inside these `<Routes />`. In documentation they say that from `v6` and on, it is an 'uncommon practice', but for the way this was thought out, it would need a major rewrite or to let as it is for readability and maintenence ease purpose.
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.
Checks have passed and this pull request is ready for manual review
Nature of PR
Description
(Link for upgrading documention to v7)
In this PR we focus on upgrading
react-router-dom
to its newest versionv7.0.2
.During this upgrade this package has been replaced in favor ofreact-router
. Of the mentioned necessary changes we had no need to do none of them since they didn't affect us really, except forv7_startTransition
inhpc-ftsadmin
.In
async-autocomplete-field.tsx
we had anuseEffect()
with the wrong variables inside of the dependency array. We decided to write all of them in order foreslint
to not raise a warning of used variables inuseEffect()
that were not in the dependency array. After further investigation this extra properties didn't cause a re-render what entered in conflict withv7_startTransition
, since with this flagreact-router
usesuseTransition()
instead ofuseState()
what makes React categorize the importance of an action. The solution I provided, was going to my latest working branch ofhpc-ftsadmin
and took the values that I had in this dependencies array since I already encountered errors on this component and provided a fix.Beside this change there is another "important" change that is to change the
tsconfig.base.json
and adding this new module resolution :We were using
node
that anyways we would have had to update tonode16
ornodenext
since we support modern versions of Node. But since we usedNx
andwebpack
I could activatebundler
mode that give us more flexibility like not having to add all the file extensions of imports what would have resulted in a "big refactor". This was mainly done to allow us to import fromreact-router/dom
, while usingnode
we could not resolve this import.I took the opportunity to implement a modern implementation of how they propose to create routers since
v6
inhpc-ftsadmin
what will allow us to use the data API that will be necessary in the development of FTS Admin v2.How to test changes
To test this change I would recommend:
"moduleResolution": "bundler"
doesn't raise any problems.hpc-ftsadmin
orhpc-cdm
.ReactRouter7Adapter
is well written.