-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add useRouter and RouterContext (#307)
BREAKING CHANGE: Pass router object through our own context rather than Redux store BREAKING CHANGE: Remove custom connector helpers
- Loading branch information
Showing
19 changed files
with
221 additions
and
159 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import createConnectedLink from './createConnectedLink'; | ||
import BaseLink from './BaseLink'; | ||
import withRouter from './withRouter'; | ||
|
||
const Link = createConnectedLink(); | ||
const Link = withRouter(BaseLink); | ||
Link.displayName = 'Link'; | ||
|
||
export default Link; |
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,3 @@ | ||
import React from 'react'; | ||
|
||
export default React.createContext(null); |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,29 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import { routerShape } from '../PropTypes'; | ||
import RouterContext from '../RouterContext'; | ||
|
||
const propTypes = { | ||
renderArgs: PropTypes.shape({ | ||
router: routerShape.isRequired, | ||
}).isRequired, | ||
children: PropTypes.node, | ||
}; | ||
|
||
function RouterProvider({ renderArgs, children }) { | ||
return ( | ||
<RouterContext.Provider | ||
value={{ | ||
router: renderArgs.router, | ||
match: renderArgs, | ||
}} | ||
> | ||
{children} | ||
</RouterContext.Provider> | ||
); | ||
} | ||
|
||
RouterProvider.propTypes = propTypes; | ||
|
||
export default RouterProvider; |
Oops, something went wrong.