Skip to content

Commit 64a1356

Browse files
authored
Merge pull request #13 from avocode/add-react16-support
Add support for React 16
2 parents 381a5b6 + 6f3355e commit 64a1356

File tree

10 files changed

+75
-44
lines changed

10 files changed

+75
-44
lines changed

example/components/app.coffee

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
immutable = require 'immutable'
22
React = require 'react'
3+
ReactDOM = require 'react-dom-factories'
4+
createClass = require 'create-react-class'
35

4-
{ div } = React.DOM
6+
{ div } = ReactDOM
57
MyListView = React.createFactory require './my-list-view'
68

79

8-
module.exports = React.createClass
10+
module.exports = createClass
911
displayName: 'App'
1012

1113
_createSubItem: (id, text) ->

example/components/foldable-list-item.coffee

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
React = require 'react'
2+
ReactDOM = require 'react-dom-factories'
3+
createClass = require 'create-react-class'
4+
PropTypes = require 'prop-types';
25

3-
{ div, span } = React.DOM
6+
{ div, span } = ReactDOM
47

58

6-
module.exports = React.createClass
9+
module.exports = createClass
710
displayName: 'FoldableListItem'
811

912
propTypes:
10-
item: React.PropTypes.object.isRequired
11-
folded: React.PropTypes.bool
13+
item: PropTypes.object.isRequired
14+
folded: PropTypes.bool
1215

1316
getDefaultProps: ->
1417
folded: true

example/components/my-list-view.coffee

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
immutable = require 'immutable'
22
React = require 'react'
3+
ReactDOM = require 'react-dom-factories'
4+
createClass = require 'create-react-class'
5+
PropTypes = require 'prop-types';
36

4-
{ div } = React.DOM
7+
{ div } = ReactDOM
58
ListView = React.createFactory require '../../src/'
69
FoldableListItem = React.createFactory require './foldable-list-item'
710
SimpleListItem = React.createFactory require './simple-list-item'
811
SimpleListSubItem = React.createFactory require './simple-list-subitem'
912

1013

11-
module.exports = React.createClass
14+
module.exports = createClass
1215
displayName: 'MyListView'
1316

1417
propTypes:
15-
things: React.PropTypes.object.isRequired
18+
things: PropTypes.object.isRequired
1619

1720
getInitialState: ->
1821
listItems: @_createListItems(@props.things)

example/components/simple-list-item.coffee

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
React = require 'react'
2+
ReactDOM = require 'react-dom-factories'
3+
createClass = require 'create-react-class'
4+
PropTypes = require 'prop-types';
25

3-
{ div, span } = React.DOM
6+
{ div, span } = ReactDOM
47

58

6-
module.exports = React.createClass
9+
module.exports = createClass
710
displayName: 'SimpleListItem'
811

912
propTypes:
10-
item: React.PropTypes.object.isRequired
13+
item: PropTypes.object.isRequired
1114

1215
render: ->
1316
div null,

example/components/simple-list-subitem.coffee

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
React = require 'react'
2+
ReactDOM = require 'react-dom-factories'
3+
createClass = require 'create-react-class'
4+
PropTypes = require 'prop-types';
25

3-
{ div, span } = React.DOM
6+
{ div, span } = ReactDOM
47

58

6-
module.exports = React.createClass
9+
module.exports = createClass
710
displayName: 'SimpleListSubItem'
811

912
propTypes:
10-
item: React.PropTypes.object.isRequired
13+
item: PropTypes.object.isRequired
1114

1215
render: ->
1316
div null,

package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,26 @@
2222
},
2323
"dependencies": {
2424
"classnames": "^2.2.5",
25-
"immutable": "^3.8.1"
25+
"create-react-class": "^15.6.3",
26+
"immutable": "^3.8.1",
27+
"prop-types": "^15.7.2",
28+
"react-dom-factories": "^1.0.2"
2629
},
2730
"peerDependencies": {
28-
"react": "^0.14.8 || ^15",
29-
"react-dom": "^0.14.8 || ^15"
31+
"react": "^0.14.8 || ^15 || ^16",
32+
"react-dom": "^0.14.8 || ^15 || ^16"
3033
},
3134
"devDependencies": {
35+
"enzyme-adapter-react-16": "^1.15.1",
3236
"chai": "^3.5.0",
3337
"coffee-loader": "^0.7.2",
3438
"coffee-script": "^1.10.0",
35-
"enzyme": "^2.3.0",
39+
"enzyme": "^3.0.0",
3640
"lodash.assign": "^4.0.9",
3741
"mocha": "^2.5.3",
42+
"react": "^16",
3843
"react-addons-test-utils": "^15.3.1",
44+
"react-dom": "^16",
3945
"sinon": "^1.17.4",
4046
"webpack": "^1.13.0",
4147
"webpack-dev-server": "^1.14.1"

src/components/list-item.coffee

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
React = require 'react'
2-
ReactDOM = require 'react-dom'
2+
ReactDOM = require 'react-dom-factories'
3+
PropTypes = require 'prop-types';
4+
createClass = require 'create-react-class'
35

4-
{ div } = React.DOM
6+
{ div } = ReactDOM
57

68
classNames = require 'classnames'
79

810

911
module.exports =
10-
React.createClass
12+
createClass
1113
displayName: 'ListItem'
1214

1315
propTypes:
14-
item: React.PropTypes.shape({
15-
id: React.PropTypes.oneOfType([
16-
React.PropTypes.string
17-
React.PropTypes.number
16+
item: PropTypes.shape({
17+
id: PropTypes.oneOfType([
18+
PropTypes.string
19+
PropTypes.number
1820
]).isRequired
1921
})
20-
selected: React.PropTypes.bool
21-
selectedClassName: React.PropTypes.string.isRequired
22-
onClickRequest: React.PropTypes.func
22+
selected: PropTypes.bool
23+
selectedClassName: PropTypes.string.isRequired
24+
onClickRequest: PropTypes.func
2325

2426
getDefaultProps: ->
2527
selected: false

src/components/list-view.coffee

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
immutable = require 'immutable'
22
React = require 'react'
3+
ReactDOM = require 'react-dom-factories'
4+
PropTypes = require 'prop-types';
5+
createClass = require 'create-react-class'
36

4-
{ div } = React.DOM
7+
{ div } = ReactDOM
58
ListItem = React.createFactory require './list-item'
69

710

811
module.exports =
9-
React.createClass
12+
createClass
1013
displayName: 'ListView'
1114

1215
propTypes:
13-
items: React.PropTypes.object.isRequired
14-
selectedItemId: React.PropTypes.oneOfType([
15-
React.PropTypes.number
16-
React.PropTypes.string
16+
items: PropTypes.object.isRequired
17+
selectedItemId: PropTypes.oneOfType([
18+
PropTypes.number
19+
PropTypes.string
1720
])
18-
collapsedItemIds: React.PropTypes.object.isRequired
19-
itemClassName: React.PropTypes.string
20-
selectedItemClassName: React.PropTypes.string
21-
ignoreCollapseClicks: React.PropTypes.bool
22-
handler: React.PropTypes.func
23-
renderItem: React.PropTypes.func
24-
onCollapseItem: React.PropTypes.func.isRequired
25-
onExpandItem: React.PropTypes.func.isRequired
26-
onSelectItem: React.PropTypes.func.isRequired
21+
collapsedItemIds: PropTypes.object.isRequired
22+
itemClassName: PropTypes.string
23+
selectedItemClassName: PropTypes.string
24+
ignoreCollapseClicks: PropTypes.bool
25+
handler: PropTypes.func
26+
renderItem: PropTypes.func
27+
onCollapseItem: PropTypes.func.isRequired
28+
onExpandItem: PropTypes.func.isRequired
29+
onSelectItem: PropTypes.func.isRequired
2730

2831
getDefaultProps: ->
2932
itemClassName: ''

test/components/list-item.spec.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
assign = require 'lodash.assign'
22
chai = require 'chai'
33
enzyme = require 'enzyme'
4+
Adapter = require 'enzyme-adapter-react-16'
45
immutable = require 'immutable'
56
React = require 'react'
67
sinon = require 'sinon'
78

89
ListItem = require '../../src/components/list-item'
910

11+
enzyme.configure({ adapter: new Adapter() });
12+
1013
expect = chai.expect
1114

1215

test/components/list-view.spec.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
assign = require 'lodash.assign'
22
chai = require 'chai'
33
enzyme = require 'enzyme'
4+
Adapter = require 'enzyme-adapter-react-16'
45
immutable = require 'immutable'
56
React = require 'react'
67
sinon = require 'sinon'
78

89
ListView = require '../../src/components/list-view'
910
ListItem = require '../../src/components/list-item'
1011

12+
enzyme.configure({ adapter: new Adapter() });
13+
1114
expect = chai.expect
1215

1316

0 commit comments

Comments
 (0)