From 5a410c72dac33a09b8912fcc2d23d5164a20056b Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Fri, 27 Jan 2017 16:29:47 -0800 Subject: [PATCH 1/2] Update context example for react-router@4.0.0-beta.1 --- docs/docs/context.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/docs/context.md b/docs/docs/context.md index 3ae11fe8b1c..beee69adb7f 100644 --- a/docs/docs/context.md +++ b/docs/docs/context.md @@ -108,9 +108,11 @@ If `contextTypes` is not defined, then `context` will be an empty object. ## Parent-Child Coupling -Context can also let you build an API where parents and children communicate. For example, one library that works this way is [React Router V4](https://react-router.now.sh/basic): +Context can also let you build an API where parents and children communicate. For example, one library that works this way is [React Router V4](https://reacttraining.com/react-router): ```javascript +import { Router, Route, Link } from 'react-router-dom' + const BasicExample = () => (
@@ -122,15 +124,15 @@ const BasicExample = () => (
- - - + + +
) ``` -By passing down some information from the `Router` component, each `Link` and `Match` can communicate back to the containing `Router`. +By passing down some information from the `Router` component, each `Link` and `Route` can communicate back to the containing `Router`. Before you build components with an API similar to this, consider if there are cleaner alternatives. For example, you can pass entire React component as props if you'd like to. From 769e88e3ee03f5cf300b736072ace553dedbffc9 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 30 Jan 2017 17:36:27 +0000 Subject: [PATCH 2/2] Style nits --- docs/docs/context.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/docs/context.md b/docs/docs/context.md index beee69adb7f..c5703d35452 100644 --- a/docs/docs/context.md +++ b/docs/docs/context.md @@ -111,7 +111,7 @@ If `contextTypes` is not defined, then `context` will be an empty object. Context can also let you build an API where parents and children communicate. For example, one library that works this way is [React Router V4](https://reacttraining.com/react-router): ```javascript -import { Router, Route, Link } from 'react-router-dom' +import { Router, Route, Link } from 'react-router-dom'; const BasicExample = () => ( @@ -122,14 +122,14 @@ const BasicExample = () => (
  • Topics
  • -
    +
    - - - + + +
    -) +); ``` By passing down some information from the `Router` component, each `Link` and `Route` can communicate back to the containing `Router`.