Last active
May 1, 2024 21:15
-
-
Save zhaocnus/6fcef1b27dd48e42b4f579eb7edc536c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // children propType | |
| Foo.propTypes = { | |
| children: PropTypes.oneOfType([ | |
| PropTypes.arrayOf(React.PropTypes.node), | |
| PropTypes.node | |
| ]) | |
| } | |
| // use react router in a component (if you have to) | |
| import withRouter from 'react-router/lib/withRouter'; | |
| const Foo = ({ router }) => ( | |
| <div onClick={() => router.push('/path')} /> | |
| ); | |
| Foo.propTypes = { | |
| router: PropTypes.object.isRequired | |
| }; | |
| export default withRouter(Foo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment