Skip to content
This repository was archived by the owner on May 15, 2022. It is now read-only.

Commit b22e973

Browse files
Removed unnecessary componentWillMount methods to set initial state. Now using ES7 property initializers instead
1 parent 29ee4b6 commit b22e973

File tree

12 files changed

+18
-58
lines changed

12 files changed

+18
-58
lines changed

dev/src/react-dat-gui/components/DatBoolean.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ export default class DatBoolean extends Component {
1313
_onUpdateValue: PropTypes.func,
1414
};
1515

16-
componentWillMount() {
17-
this.setState({
18-
value: this.getValue()
19-
});
16+
state = {
17+
value: this.getValue(),
2018
}
2119

2220
componentWillReceiveProps(nextProps) {

dev/src/react-dat-gui/components/DatColor.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ export default class DatColor extends Component {
2121
displayColorPicker: false,
2222
}
2323

24-
componentWillMount() {
25-
this.setState({
26-
value: this.getValue()
27-
});
28-
}
29-
3024
componentWillReceiveProps(nextProps) {
3125
this.setState({
3226
value: this.getValue(nextProps)

dev/src/react-dat-gui/components/DatNumber.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ export default class DatNumber extends Component {
2121
_onUpdateValue: PropTypes.func,
2222
};
2323

24-
componentWillMount() {
25-
this.setState({
26-
value: this.getValue()
27-
});
24+
state = {
25+
value: this.getValue(),
2826
}
2927

3028
componentWillReceiveProps(nextProps) {

dev/src/react-dat-gui/components/DatSelect.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ export default class DatSelect extends Component {
1818

1919
state = {
2020
value: '',
21-
options: [this.getValue(), ...this.props.options]
22-
}
23-
24-
componentWillMount() {
25-
this.setState({
26-
value: this.getValue()
27-
});
21+
options: [this.getValue(), ...this.props.options],
2822
}
2923

3024
componentWillReceiveProps(nextProps) {

dev/src/react-dat-gui/components/DatString.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ export default class DatString extends Component {
1515
_onUpdateValue: PropTypes.func,
1616
};
1717

18-
componentWillMount() {
19-
this.setState({
20-
value: this.getValue()
21-
});
18+
state = {
19+
value: this.getValue(),
2220
}
2321

2422
componentWillReceiveProps(nextProps) {

dev/src/react-dat-gui/components/Slider.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ export default class Slider extends Component {
1414
onUpdate: PropTypes.func,
1515
};
1616

17-
componentWillMount() {
18-
this.setState({
19-
value: toNumber(this.props.value)
20-
});
17+
state = {
18+
value: toNumber(this.props.value),
2119
}
2220

2321
componentWillReceiveProps(nextProps) {

src/components/DatBoolean.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ export default class DatBoolean extends Component {
1313
_onUpdateValue: PropTypes.func,
1414
};
1515

16-
componentWillMount() {
17-
this.setState({
18-
value: this.getValue()
19-
});
16+
state = {
17+
value: this.getValue(),
2018
}
2119

2220
componentWillReceiveProps(nextProps) {

src/components/DatColor.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ export default class DatColor extends Component {
2121
displayColorPicker: false,
2222
}
2323

24-
componentWillMount() {
25-
this.setState({
26-
value: this.getValue()
27-
});
28-
}
29-
3024
componentWillReceiveProps(nextProps) {
3125
this.setState({
3226
value: this.getValue(nextProps)

src/components/DatNumber.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ export default class DatNumber extends Component {
2121
_onUpdateValue: PropTypes.func,
2222
};
2323

24-
componentWillMount() {
25-
this.setState({
26-
value: this.getValue()
27-
});
24+
state = {
25+
value: this.getValue(),
2826
}
2927

3028
componentWillReceiveProps(nextProps) {

src/components/DatSelect.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ export default class DatSelect extends Component {
1818

1919
state = {
2020
value: '',
21-
options: [this.getValue(), ...this.props.options]
22-
}
23-
24-
componentWillMount() {
25-
this.setState({
26-
value: this.getValue()
27-
});
21+
options: [this.getValue(), ...this.props.options],
2822
}
2923

3024
componentWillReceiveProps(nextProps) {

0 commit comments

Comments
 (0)