mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 04:33:10 +00:00
Remove react proptypes references (#9759)
This commit is contained in:
committed by
Sophie Alpert
parent
06c17fbfad
commit
93bb40e871
@@ -10,8 +10,8 @@ var IS_MOBILE = (
|
||||
|
||||
var CodeMirrorEditor = React.createClass({
|
||||
propTypes: {
|
||||
lineNumbers: React.PropTypes.bool,
|
||||
onChange: React.PropTypes.func,
|
||||
lineNumbers: PropTypes.bool,
|
||||
onChange: PropTypes.func,
|
||||
},
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
@@ -80,12 +80,12 @@ var ReactPlayground = React.createClass({
|
||||
MODES: {JSX: 'JSX', JS: 'JS'}, //keyMirror({JSX: true, JS: true}),
|
||||
|
||||
propTypes: {
|
||||
codeText: React.PropTypes.string.isRequired,
|
||||
transformer: React.PropTypes.func,
|
||||
renderCode: React.PropTypes.bool,
|
||||
showCompiledJSTab: React.PropTypes.bool,
|
||||
showLineNumbers: React.PropTypes.bool,
|
||||
editorTabTitle: React.PropTypes.string,
|
||||
codeText: PropTypes.string.isRequired,
|
||||
transformer: PropTypes.func,
|
||||
renderCode: PropTypes.bool,
|
||||
showCompiledJSTab: PropTypes.bool,
|
||||
showLineNumbers: PropTypes.bool,
|
||||
editorTabTitle: PropTypes.string,
|
||||
},
|
||||
|
||||
getDefaultProps: function() {
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<script src="https://unpkg.com/codemirror@5.15.2/mode/javascript/javascript.js"></script>
|
||||
<script src="https://unpkg.com/codemirror@5.15.2/mode/xml/xml.js"></script>
|
||||
<script src="https://unpkg.com/codemirror@5.15.2/mode/jsx/jsx.js"></script>
|
||||
<script src="https://unpkg.com/prop-types/prop-types.min.js"></script>
|
||||
<script src="https://unpkg.com/react/dist/react.min.js"></script>
|
||||
<script src="https://unpkg.com/react-dom/dist/react-dom.min.js"></script>
|
||||
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
|
||||
|
||||
@@ -18,7 +18,7 @@ The normal usage of PropTypes is still supported:
|
||||
|
||||
```javascript
|
||||
Button.propTypes = {
|
||||
highlighted: React.PropTypes.bool
|
||||
highlighted: PropTypes.bool
|
||||
};
|
||||
```
|
||||
|
||||
@@ -29,9 +29,9 @@ Nothing changes here.
|
||||
Using PropTypes in any other way than annotating React components with them is no longer supported:
|
||||
|
||||
```javascript
|
||||
var apiShape = React.PropTypes.shape({
|
||||
body: React.PropTypes.object,
|
||||
statusCode: React.PropTypes.number.isRequired
|
||||
var apiShape = PropTypes.shape({
|
||||
body: PropTypes.object,
|
||||
statusCode: PropTypes.number.isRequired
|
||||
}).isRequired;
|
||||
|
||||
// Not supported!
|
||||
@@ -49,13 +49,13 @@ Inspect the stack trace produced by the warning. You will find the component def
|
||||
```js
|
||||
Button.propTypes = {
|
||||
highlighted: ThirdPartyPropTypes.deprecated(
|
||||
React.PropTypes.bool,
|
||||
PropTypes.bool,
|
||||
'Use `active` prop instead'
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
In this case, `ThirdPartyPropTypes.deprecated` is a wrapper calling `React.PropTypes.bool`. This pattern by itself is fine, but triggers a false positive because React thinks you are calling PropTypes directly. The next section explains how to fix this problem for a library implementing something like `ThirdPartyPropTypes`. If it's not a library you wrote, you can file an issue against it.
|
||||
In this case, `ThirdPartyPropTypes.deprecated` is a wrapper calling `PropTypes.bool`. This pattern by itself is fine, but triggers a false positive because React thinks you are calling PropTypes directly. The next section explains how to fix this problem for a library implementing something like `ThirdPartyPropTypes`. If it's not a library you wrote, you can file an issue against it.
|
||||
|
||||
### Fixing the false positive in third party PropTypes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user