Skip to content

Commit abc274b

Browse files
authored
Fix #109 and support React 16 (#111)
1 parent e482a2a commit abc274b

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "react-html5video-demo",
33
"dependencies": {
4-
"react": "^15.4.0",
5-
"react-dom": "^15.4.0",
4+
"react": "^16.0.0-rc.3",
5+
"react-dom": "^16.0.0-rc.3",
66
"react-html5video": "file:../",
77
"reset-css": "^2.2.0"
88
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
"react-hot-loader": "^3.0.0-beta.6",
9595
"react-svg-loader": "^1.1.1",
9696
"react-test-renderer": "^15.5.4",
97-
"recompose": "^0.20.2",
9897
"style-loader": "^0.13.1",
9998
"url-loader": "^0.5.7",
10099
"webpack": "^1.13.3",

src/video/video.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
import React, { Component } from 'react';
77
import { findDOMNode } from 'react-dom';
8-
import toClass from 'recompose/toClass';
98
import {
109
EVENTS,
1110
PROPERTIES,
@@ -33,10 +32,7 @@ export default (
3332
mapStateToProps = defaultMapStateToProps,
3433
mapVideoElToProps = defaultMapVideoElToProps,
3534
mergeProps = defaultMergeProps
36-
) => {
37-
const BaseComponentClass = toClass(BaseComponent);
38-
39-
class Video extends Component {
35+
) => class Video extends Component {
4036
constructor(props) {
4137
super(props);
4238
this.updateState = this.updateState.bind(this);
@@ -121,14 +117,13 @@ export default (
121117
this.props
122118
);
123119
return (
124-
<BaseComponentClass
125-
ref={this.setRef.bind(this)}
126-
{...mergeProps(
127-
stateProps,
128-
videoElProps,
129-
this.props)} />
120+
<div ref={this.setRef.bind(this)}>
121+
<BaseComponent
122+
{...mergeProps(
123+
stateProps,
124+
videoElProps,
125+
this.props)} />
126+
</div>
130127
);
131128
}
132129
}
133-
return Video;
134-
}

src/video/video.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ describe('video', () => {
133133
});
134134

135135
it('returns a component with it\'s ownProps', () => {
136-
expect(component.prop('autoPlay'))
136+
expect(component.find(TestVideo).prop('autoPlay'))
137137
.toBe(true);
138138
});
139139

140140
it('returns a component with a videoEl prop', () => {
141-
expect(component.prop('videoEl'))
141+
expect(component.find(TestVideo).prop('videoEl'))
142142
.toBe(videoEl);
143143
});
144144

@@ -151,7 +151,7 @@ describe('video', () => {
151151
}
152152
};
153153
component.setState(state);
154-
expect(component.prop('video'))
154+
expect(component.find(TestVideo).prop('video'))
155155
.toEqual(state);
156156
});
157157

@@ -168,9 +168,9 @@ describe('video', () => {
168168
component.setState({
169169
paused: true
170170
});
171-
expect(component.prop('state').paused)
171+
expect(component.find(TestVideo).prop('state').paused)
172172
.toBe(true);
173-
expect(component.prop('ownProps').autoPlay)
173+
expect(component.find(TestVideo).prop('ownProps').autoPlay)
174174
.toBe(true);
175175
});
176176

@@ -187,7 +187,7 @@ describe('video', () => {
187187
);
188188
component.instance().videoEl = videoEl;
189189
component.instance().forceUpdate();
190-
component.prop('togglePlay')();
190+
component.find(TestVideo).prop('togglePlay')();
191191
expect(videoEl.play).toHaveBeenCalledWith('testValue');
192192
});
193193

@@ -200,7 +200,7 @@ describe('video', () => {
200200
const component = shallow(
201201
<Component />
202202
);
203-
expect(component.prop('duplicateKey')).toBe('mapVideoElToProps');
203+
expect(component.find(TestVideo).prop('duplicateKey')).toBe('mapVideoElToProps');
204204
});
205205

206206
it('allows ownProps to take precedence over mapVideoElToProps and mapStateToProps', () => {
@@ -212,7 +212,7 @@ describe('video', () => {
212212
const component = shallow(
213213
<Component duplicateKey="ownProps" />
214214
);
215-
expect(component.prop('duplicateKey')).toBe('ownProps');
215+
expect(component.find(TestVideo).prop('duplicateKey')).toBe('ownProps');
216216
});
217217

218218
it('allows cusomtisation of merging ownProps, mapVideoElToProps and mapStateToProps to change the merging precedence', () => {
@@ -225,7 +225,7 @@ describe('video', () => {
225225
const component = shallow(
226226
<Component duplicateKey="ownProps" />
227227
);
228-
expect(component.prop('duplicateKey')).toBe('mapVideoElToProps');
228+
expect(component.find(TestVideo).prop('duplicateKey')).toBe('mapVideoElToProps');
229229
});
230230
});
231231
});

0 commit comments

Comments
 (0)