Support react-router 6#275
Conversation
| }) as ((oktaAuth: OktaAuth, originalUri?: string) => Promise<void>); | ||
|
|
||
| return () => { | ||
| // Restore original callback |
|
|
||
| return () => { | ||
| // Restore original callback | ||
| oktaAuth.options.restoreOriginalUri = originalCallback; |
There was a problem hiding this comment.
I don't think this is necessary, the Security component should never unmount
There was a problem hiding this comment.
This cleanup function fixes the issue with React 18 StrictMode.
If you run test/apps/v6-app sample app without it, you can notice the warning Two custom restoreOriginalUri callbacks are detected. The one from the OktaAuth configuration will be overridden by the provided restoreOriginalUri prop from the Security component.
It happens because effects run twice
There was a problem hiding this comment.
Oh interesting, that's probably because StrictMode was changed in React18 to do a double mount
I wonder if we should use this approach instead: https://react.dev/learn/you-might-not-need-an-effect#initializing-the-application
Trevor used it as well for something similar: #266
There was a problem hiding this comment.
Changed to global var approach.
This required a workaround for tests: 0132a0e
|
this is really useful, even the updates to the docs are super convenient and helped me a lot. |
|
Hi everyone We are upgrading an old application to the latest version okta-react and are encountering the same issue of SecureRoute no longer working after going to version Version 6. Will this update be released soon? |
|
We don't have an official timeline, this is a major version release, so we are proceeding carefully |
Ok, thank you for the clarification! |
OKTA-676780 Support react-router 6
OKTA-676780 Support react-router 6
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: OKTA-676780
Resolves #178
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Reviewers