Use ES6 module instead of commonJS (#10953)
* Use ES6 module instead of commonJS As far as I know, we're using ES6 modules throughout the docs. For the sake of consistency :) * Convert all CommonJS requires to ES6 module
Joshua committed
Sep 29, 2017 at 06:24 UTC
3a4c2a661fd875c98d9589922545fb98457611cf
1 file changed
+3
-3
docs/docs/context.md
+3
-3
@@ -67,7 +67,7 @@ class MessageList extends React.Component {
67
In this example, we manually thread through a `color` prop in order to style the `Button` and `Message` components appropriately. Using context, we can pass this through the tree automatically:
68
69
```javascript{6,13-15,21,28-30,40-42}
70
-const PropTypes = require('prop-types');
70
+import PropTypes from 'prop-types';
71
72
class Button extends React.Component {
73
render() {
@@ -163,7 +163,7 @@ If `contextTypes` is defined within a component, the following [lifecycle method
163
Stateless functional components are also able to reference `context` if `contextTypes` is defined as a property of the function. The following code shows a `Button` component written as a stateless functional component.
164
165
```javascript
166
-const PropTypes = require('prop-types');
166
+import PropTypes from 'prop-types';
167
168
const Button = ({children}, context) =>
169
<button style={{'{{'}}background: context.color}}>
@@ -182,7 +182,7 @@ React has an API to update context, but it is fundamentally broken and you shoul
182
The `getChildContext` function will be called when the state or props changes. In order to update data in the context, trigger a local state update with `this.setState`. This will trigger a new context and changes will be received by the children.
183
184
```javascript
185
-const PropTypes = require('prop-types');
185
+import PropTypes from 'prop-types';
186
187
class MediaQuery extends React.Component {
188
constructor(props) {