Skip to content

Commit 02c7b10

Browse files
committed
Update README.md
1 parent 87c7e64 commit 02c7b10

File tree

1 file changed

+6
-39
lines changed

1 file changed

+6
-39
lines changed

README.md

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,52 +72,19 @@ class Title extends React.Component<{ children: Node }> {
7272
}
7373
```
7474

75-
## Usage with React 15 and below
75+
## Compatibility
7676

77-
`Provider` just returns its children in its `render` method, and `Consumer` returns the result of child function call. This means that whatever value you give as `Provider` children, or return from `Consumer` child function, it should be a valid `render` return type for your current React version. For React 15, it includes React element, boolean, and null, but doesn't include fragments (arrays), strings, or numbers.
77+
This package only "ponyfills" the `React.createContext` API, not other
78+
unrelated React 16+ APIs. If you are using a version of React <16, keep
79+
in mind that you can only use features available in that version.
7880

81+
For example, you cannot pass children types aren't valid pre React 16:
7982

8083
```js
81-
// Works in React 15 and below
82-
83-
<Context.Provider><span>foo</span></Context.Provider>
84-
85-
<Context.Provider>
86-
<div>
87-
<div/>
88-
<div/>
89-
</div>
90-
</Context.Provider>
91-
92-
<Context.Consumer>{value => <span>{Number(value)}</span>}</Context.Consumer>
93-
94-
<Context.Consumer>
95-
{value => (
96-
<div>
97-
<div/>
98-
<div/>
99-
</div>
100-
)}
101-
</Context.Consumer>
102-
```
103-
104-
```js
105-
// Doesn't work in React 15 and below
106-
107-
<Context.Provider>foo</Context.Provider>
108-
10984
<Context.Provider>
11085
<div/>
11186
<div/>
11287
</Context.Provider>
113-
114-
<Context.Consumer>{value => Number(value)}</Context.Consumer>
115-
116-
<Context.Consumer>
117-
{value => [
118-
<div/>,
119-
<div/>
120-
]}
121-
</Context.Consumer>
12288
```
12389

90+

0 commit comments

Comments
 (0)