@@ -4,6 +4,15 @@ var EnhancedButton = require('./enhanced-button');
44var FontIcon = require ( './font-icon' ) ;
55var Paper = require ( './paper' ) ;
66
7+ var getZDepth = function ( disabled ) {
8+ var zDepth = disabled ? 0 : 2 ;
9+ return {
10+ zDepth : zDepth ,
11+ initialZDepth : zDepth
12+ } ;
13+ } ;
14+
15+
716var RaisedButton = React . createClass ( {
817
918 mixins : [ Classable ] ,
@@ -20,12 +29,14 @@ var RaisedButton = React.createClass({
2029 secondary : React . PropTypes . bool
2130 } ,
2231
23- getInitialState : function ( ) {
24- var zDepth = this . props . disabled ? 0 : 2 ;
25- return {
26- zDepth : zDepth ,
27- initialZDepth : zDepth
28- } ;
32+ componentWillMount : function ( ) {
33+ this . setState ( getZDepth ( this . props . disabled ) ) ;
34+ } ,
35+
36+ componentWillReceiveProps : function ( newProps ) {
37+ if ( newProps . disabled !== this . props . disabled ) {
38+ this . setState ( getZDepth ( newProps . disabled ) ) ;
39+ }
2940 } ,
3041
3142 componentDidMount : function ( ) {
@@ -63,7 +74,7 @@ var RaisedButton = React.createClass({
6374 circle = { true } >
6475
6576 < EnhancedButton { ...other }
66- className = "mui-floating-action-button-container"
77+ className = "mui-floating-action-button-container"
6778 onMouseDown = { this . _handleMouseDown }
6879 onMouseUp = { this . _handleMouseUp }
6980 onMouseOut = { this . _handleMouseOut }
@@ -74,7 +85,7 @@ var RaisedButton = React.createClass({
7485 { this . props . children }
7586
7687 </ EnhancedButton >
77-
88+
7889 </ Paper >
7990 ) ;
8091 } ,
0 commit comments