-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX Set correct proptypes for react components
- Loading branch information
1 parent
0f3cf3c
commit d8fbfef
Showing
9 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { useLocation, useNavigate, useParams } from 'react-router-dom'; | ||
|
||
// Essentially a polyfill for the old withRouter hoc that came with react-router-dom | ||
// This should really be replaced by using the hooks directly instead of as props but | ||
// refactoring for that would take way longer than just adding this polyfill | ||
export default function withRouter(ComponentToWrap) { | ||
function ComponentWithRouterProp(props) { | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
const params = useParams(); | ||
return ( | ||
<ComponentToWrap | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
router={{ location, navigate, params }} | ||
/> | ||
); | ||
} | ||
return ComponentWithRouterProp; | ||
} |