Skip to content

Commit bc189af

Browse files
authored
Merge pull request mac-s-g#109 from mac-s-g/react-16-warning
fixed mac-s-g#107 I'll update when a patch version update is merged and published to npm.
2 parents 93285c1 + 9177e6a commit bc189af

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/js/components/DataTypes/Object.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ class rjvObject extends React.Component {
3131

3232
constructor(props) {
3333
super(props);
34-
this.init(props);
34+
this.state = this.initializeState(props);
3535
}
3636

3737
state = {}
3838

39-
init = (props) => {
39+
initializeState = (props) => {
4040
const expanded = (
4141
props.collapsed === false
4242
|| (props.collapsed !== true
@@ -58,12 +58,11 @@ class rjvObject extends React.Component {
5858
display_name: (props.name ? props.name : '')
5959
}
6060

61-
this.state = {...this.state, ...state};
61+
return {...this.state, ...state};
6262
}
6363

6464
componentWillReceiveProps(nextProps) {
65-
this.init(nextProps);
66-
this.setState(this.state);
65+
this.setState(this.initializeState(nextProps));
6766
}
6867

6968
toggleCollapsed = () => {

0 commit comments

Comments
 (0)