Skip to content

Commit 5e787d4

Browse files
committed
fix: implement a fix for React warning
1 parent 7a87ee3 commit 5e787d4

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/extendReactClass.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export default (Component: Object, defaultStyles: Object, options: Object) => {
1818
let styles;
1919

2020
const hasDefaultstyles = _.isObject(defaultStyles);
21-
21+
22+
let renderResult;
23+
2224
if (this.props.styles || hasDefaultstyles) {
2325
const props = Object.assign({}, this.props);
2426

@@ -35,14 +37,31 @@ export default (Component: Object, defaultStyles: Object, options: Object) => {
3537
value: styles,
3638
writable: false
3739
});
40+
41+
const originalProps = this.props;
42+
43+
let renderIsSuccessful = false;
3844

39-
this.props = props;
45+
try {
46+
this.props = props;
47+
48+
renderResult = super.render();
49+
50+
renderIsSuccessful = true;
51+
} finally {
52+
this.props = originalProps;
53+
}
54+
55+
// @see https://github.com/facebook/react/issues/14224
56+
if (!renderIsSuccessful) {
57+
renderResult = super.render();
58+
}
4059
} else {
4160
styles = {};
61+
62+
renderResult = super.render();
4263
}
4364

44-
const renderResult = super.render();
45-
4665
if (renderResult) {
4766
return linkClass(renderResult, styles, options);
4867
}

0 commit comments

Comments
 (0)