File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ export default class Vec3Widget extends React.Component {
1313 constructor ( props ) {
1414 super ( props ) ;
1515 this . state = {
16- x : this . props . value . x ,
17- y : this . props . value . y ,
18- z : this . props . value . z
16+ x : props . value . x ,
17+ y : props . value . y ,
18+ z : props . value . z
1919 } ;
2020 }
2121
@@ -27,6 +27,10 @@ export default class Vec3Widget extends React.Component {
2727 } ) ;
2828 }
2929
30+ componentWillReceiveProps ( nextProps ) {
31+ this . setState ( nextProps . value ) ;
32+ }
33+
3034 render ( ) {
3135 const widgetProps = {
3236 componentname : this . props . componentname ,
@@ -35,11 +39,11 @@ export default class Vec3Widget extends React.Component {
3539 } ;
3640
3741 return (
38- < div className = 'vec3' >
39- < NumberWidget name = 'x' value = { this . state . x } { ...widgetProps } />
40- < NumberWidget name = 'y' value = { this . state . y } { ...widgetProps } />
41- < NumberWidget name = 'z' value = { this . state . z } { ...widgetProps } />
42- </ div >
42+ < div className = 'vec3' >
43+ < NumberWidget name = 'x' value = { this . state . x } { ...widgetProps } />
44+ < NumberWidget name = 'y' value = { this . state . y } { ...widgetProps } />
45+ < NumberWidget name = 'z' value = { this . state . z } { ...widgetProps } />
46+ </ div >
4347 ) ;
4448 }
4549}
You can’t perform that action at this time.
0 commit comments