Skip to content

Commit 118ed58

Browse files
authored
Fix README for latest React changes
1 parent 9ef2f84 commit 118ed58

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

README.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -119,42 +119,41 @@ For example, while the `propTypesHandler` expects the prop types definition to b
119119
For the following component
120120

121121
```js
122-
var React = require('react');
122+
import React, { Component } from 'react';
123+
import PropTypes from 'prop-types';
123124

124125
/**
125126
* General component description.
126127
*/
127-
var Component = React.createClass({
128-
propTypes: {
129-
/**
130-
* Description of prop "foo".
131-
*/
132-
foo: React.PropTypes.number,
133-
/**
134-
* Description of prop "bar" (a custom validation function).
135-
*/
136-
bar: function(props, propName, componentName) {
137-
// ...
138-
},
139-
baz: React.PropTypes.oneOfType([
140-
React.PropTypes.number,
141-
React.PropTypes.string
142-
]),
143-
},
144-
145-
getDefaultProps: function() {
146-
return {
147-
foo: 42,
148-
bar: 21
149-
};
150-
},
151-
128+
class MyComponent extends Component {
152129
render: function() {
153130
// ...
154131
}
155-
});
132+
}
156133

157-
module.exports = Component;
134+
MyComponent.propTypes = {
135+
/**
136+
* Description of prop "foo".
137+
*/
138+
foo: PropTypes.number,
139+
/**
140+
* Description of prop "bar" (a custom validation function).
141+
*/
142+
bar: function(props, propName, componentName) {
143+
// ...
144+
},
145+
baz: PropTypes.oneOfType([
146+
PropTypes.number,
147+
PropTypes.string
148+
]),
149+
};
150+
151+
MyComponent.defaultProps = {
152+
foo: 42,
153+
bar: 21
154+
};
155+
156+
export default Component;
158157
```
159158

160159
we are getting this output:

0 commit comments

Comments
 (0)