Skip to content

Commit 1f22b63

Browse files
ryankshawmichaelbrewerdavis
authored andcommitted
npx jscodeshift -t ../react-codemod/transforms/React-PropTypes-to-prop-types.js src
1 parent 40b7017 commit 1f22b63

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"webpack-dev-server": "^1.12.0"
4848
},
4949
"dependencies": {
50-
"classnames": "^2.2.1"
50+
"classnames": "^2.2.1",
51+
"prop-types": "^15"
5152
}
5253
}

src/combobox.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var PropTypes = require('prop-types');
12
var React = require('react');
23
var guid = 0;
34
var k = function(){};
@@ -10,7 +11,7 @@ var input = React.createFactory('input');
1011

1112
class Combobox extends React.Component {
1213
static propTypes = {
13-
onFocus: React.PropTypes.func,
14+
onFocus: PropTypes.func,
1415

1516
/**
1617
* Called when the combobox receives user input, this is your chance to
@@ -22,7 +23,7 @@ class Combobox extends React.Component {
2223
* function(userInput){}
2324
* ```
2425
*/
25-
onInput: React.PropTypes.func,
26+
onInput: PropTypes.func,
2627

2728
/**
2829
* Called when the combobox receives a selection. You probably want to reset
@@ -34,12 +35,12 @@ class Combobox extends React.Component {
3435
* function(selectedValue){}
3536
* ```
3637
*/
37-
onSelect: React.PropTypes.func,
38+
onSelect: PropTypes.func,
3839

3940
/**
4041
* Shown when the combobox is empty.
4142
*/
42-
placeholder: React.PropTypes.string
43+
placeholder: PropTypes.string
4344
};
4445

4546
static defaultProps = {
@@ -455,7 +456,7 @@ class Combobox extends React.Component {
455456
}, this.state.menu.children)
456457
);
457458
}
458-
};
459+
}
459460

460461
function getLabel(component) {
461462
return component.props.label || component.props.children;

src/main.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var PropTypes = require('prop-types');
12
var React = require('react');
23
var Combobox = React.createFactory(require('./combobox'));
34
var Token = React.createFactory(require('./token'));
@@ -8,17 +9,17 @@ var li = React.DOM.li;
89

910
class TokenInput extends React.Component {
1011
static propTypes = {
11-
isLoading: React.PropTypes.bool,
12-
loadingComponent: React.PropTypes.any,
13-
onFocus: React.PropTypes.func,
14-
onInput: React.PropTypes.func.isRequired,
15-
onSelect: React.PropTypes.func.isRequired,
16-
tokenAriaFunc: React.PropTypes.func,
17-
onRemove: React.PropTypes.func.isRequired,
18-
selected: React.PropTypes.array.isRequired,
19-
menuContent: React.PropTypes.any,
20-
showListOnFocus: React.PropTypes.bool,
21-
placeholder: React.PropTypes.string
12+
isLoading: PropTypes.bool,
13+
loadingComponent: PropTypes.any,
14+
onFocus: PropTypes.func,
15+
onInput: PropTypes.func.isRequired,
16+
onSelect: PropTypes.func.isRequired,
17+
tokenAriaFunc: PropTypes.func,
18+
onRemove: PropTypes.func.isRequired,
19+
selected: PropTypes.array.isRequired,
20+
menuContent: PropTypes.any,
21+
showListOnFocus: PropTypes.bool,
22+
placeholder: PropTypes.string
2223
};
2324

2425
state = {

src/option.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var PropTypes = require('prop-types');
12
var React = require('react');
23
var addClass = require('./add-class');
34
var div = React.createFactory('div');
@@ -9,18 +10,18 @@ class Option extends React.Component {
910
* The value that will be sent to the `onSelect` handler of the
1011
* parent Combobox.
1112
*/
12-
value: React.PropTypes.any.isRequired,
13+
value: PropTypes.any.isRequired,
1314

1415
/**
1516
* What value to put into the input element when this option is
1617
* selected, defaults to its children coerced to a string.
1718
*/
18-
label: React.PropTypes.string,
19+
label: PropTypes.string,
1920

2021
/**
2122
* Whether the element should be selectable
2223
*/
23-
isFocusable: React.PropTypes.bool
24+
isFocusable: PropTypes.bool
2425
};
2526

2627
static defaultProps = {
@@ -39,6 +40,6 @@ class Option extends React.Component {
3940
}
4041
return div(props);
4142
}
42-
};
43+
}
4344

4445
module.exports = Option;

webpack.dist.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ module.exports = {
1010

1111
externals: [
1212
'react',
13-
'react-dom'
13+
'react-dom',
14+
'prop-types'
1415
],
1516

1617
output: {

0 commit comments

Comments
 (0)