@@ -16,14 +16,7 @@ var PlotlyComponent = React.createClass({
16
16
onSelected : React . PropTypes . func
17
17
} ,
18
18
19
- shouldComponentUpdate ( nextProps ) {
20
- //TODO logic for detecting change in props
21
- return true ;
22
- } ,
23
-
24
- componentDidMount ( ) {
25
- let { data, layout, config} = this . props ;
26
- Plotly . newPlot ( this . container , data , cloneDeep ( layout ) , config ) ; //We clone the layout as plotly mutates it.
19
+ attachListeners : function ( ) {
27
20
if ( this . props . onClick )
28
21
this . container . on ( 'plotly_click' , this . props . onClick ) ;
29
22
if ( this . props . onBeforeHover )
@@ -36,10 +29,22 @@ var PlotlyComponent = React.createClass({
36
29
this . container . on ( 'plotly_selected' , this . props . onSelected ) ;
37
30
} ,
38
31
32
+ shouldComponentUpdate ( nextProps ) {
33
+ //TODO logic for detecting change in props
34
+ return true ;
35
+ } ,
36
+
37
+ componentDidMount ( ) {
38
+ let { data, layout, config} = this . props ;
39
+ Plotly . newPlot ( this . container , data , cloneDeep ( layout ) , config ) ; //We clone the layout as plotly mutates it.
40
+ this . attachListeners ( ) ;
41
+ } ,
42
+
39
43
componentDidUpdate ( prevProps ) {
40
44
//TODO use minimal update for given changes
41
45
if ( prevProps . data !== this . props . data || prevProps . layout !== this . props . layout ) {
42
46
Plotly . newPlot ( this . container , this . props . data , this . props . layout ) ;
47
+ this . attachListeners ( ) ;
43
48
}
44
49
} ,
45
50
0 commit comments