Skip to content

Instantly share code, notes, and snippets.

@zhaocnus
Last active May 1, 2024 21:15
Show Gist options
  • Select an option

  • Save zhaocnus/6fcef1b27dd48e42b4f579eb7edc536c to your computer and use it in GitHub Desktop.

Select an option

Save zhaocnus/6fcef1b27dd48e42b4f579eb7edc536c to your computer and use it in GitHub Desktop.
// 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