Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pass the `router` instance down to Route children; React 0.13.3, React Router 1.0.0beta-4, ES2015, ES6
import React from 'react';
// Top-level Route component receives the router in context and passes it onto each child's props
export default class AppView extends React.Component {
render() {
return (
<div className="container">
// Add `props.router` to each route component, c => {
return React.cloneElement(c, { ...c.props, router: this.context.router });
AppView.contextTypes = {
router: React.PropTypes.object.isRequired
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment