Slight decouple from react-router-dom@5 #188
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix: allow dependents to utilize react-router-dom@latest with less specific import
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?
When users currently try to utilize react-router-dom@latest, the SecureRoute component imports fail builds because it relies on react-router-dom@5 SDK. This happens even if users aren't utilizing this component because this package is exported as a single rollup.
Issue Number: 176, 177
What is the new behavior?
Use
import * as ReactRouterDom
and then utilize possibly null properties. This brings the use of the removeduseRouteMatch
hook to a runtime check rather than expecting it to exist at build time.Does this PR introduce a breaking change?
Other information
Tried to make this as low risk as possible. It's also worth noting that the
RouteProps
type has to exist on the import at build-time. Thankfully, react-router-dom@latest currently does export a type by this name. If they change that in the future then the problem will return. But for now it's all good. Either way that issue doesn't break any case that isn't already not working.Reviewers