File tree Expand file tree Collapse file tree 2 files changed +47
-19
lines changed
components/error/CallbackGraph Expand file tree Collapse file tree 2 files changed +47
-19
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react' ;
2
2
import './CallbackGraphContainer.css' ;
3
3
4
- import viz from 'viz.js' ;
4
+ import Viz from 'viz.js' ;
5
+ import { Module , render } from 'viz.js/full.render' ;
5
6
6
7
import PropTypes from 'prop-types' ;
7
8
8
9
class CallbackGraphContainer extends Component {
9
10
constructor ( props ) {
10
11
super ( props ) ;
12
+
13
+ this . viz = null ;
14
+ this . updateViz = this . updateViz . bind ( this ) ;
15
+ }
16
+
17
+ componentDidMount ( ) {
18
+ this . updateViz ( ) ;
19
+ }
20
+
21
+ componentDidUpdate ( ) {
22
+ this . updateViz ( ) ;
11
23
}
24
+
12
25
render ( ) {
26
+ return < div className = "dash-callback-dag--container" ref = "el" /> ;
27
+ }
28
+
29
+ updateViz ( ) {
30
+ this . viz = this . viz || new Viz ( { Module, render} ) ;
31
+
13
32
const { dependenciesRequest} = this . props ;
14
33
const elements = { } ;
15
34
const callbacks = [ ] ;
@@ -55,14 +74,21 @@ class CallbackGraphContainer extends Component {
55
74
56
75
${ links . join ( '\n' ) } }` ;
57
76
58
- return (
59
- < div
60
- className = "dash-callback-dag--container"
61
- dangerouslySetInnerHTML = { {
62
- __html : viz ( dot , { format : 'svg' } ) ,
63
- } }
64
- />
65
- ) ;
77
+ const el = this . refs . el ;
78
+
79
+ this . viz
80
+ . renderSVGElement ( dot )
81
+ . then ( vizEl => {
82
+ el . innerHTML = '' ;
83
+ el . appendChild ( vizEl ) ;
84
+ } )
85
+ . catch ( e => {
86
+ // https://github.com/mdaines/viz.js/wiki/Caveats
87
+ this . viz = new Viz ( { Module, render} ) ;
88
+ // eslint-disable-next-line no-console
89
+ console . error ( e ) ;
90
+ el . innerHTML = 'Error creating callback graph' ;
91
+ } ) ;
66
92
}
67
93
}
68
94
Original file line number Diff line number Diff line change @@ -19,16 +19,18 @@ const initializeStore = reset => {
19
19
20
20
const reducer = createReducer ( ) ;
21
21
22
- // only attach logger to middleware in non-production mode
23
- store =
24
- process . env . NODE_ENV === 'production' // eslint-disable-line no-process-env
25
- ? createStore ( reducer , applyMiddleware ( thunk ) )
26
- : createStore (
27
- reducer ,
28
- window . __REDUX_DEVTOOLS_EXTENSION__ &&
29
- window . __REDUX_DEVTOOLS_EXTENSION__ ( ) ,
30
- applyMiddleware ( thunk )
31
- ) ;
22
+ // eslint-disable-next-line no-process-env
23
+ if ( process . env . NODE_ENV === 'production' ) {
24
+ store = createStore ( reducer , applyMiddleware ( thunk ) ) ;
25
+ } else {
26
+ // only attach logger to middleware in non-production mode
27
+ const reduxDTEC = window . __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ;
28
+ if ( reduxDTEC ) {
29
+ store = createStore ( reducer , reduxDTEC ( applyMiddleware ( thunk ) ) ) ;
30
+ } else {
31
+ store = createStore ( reducer , applyMiddleware ( thunk ) ) ;
32
+ }
33
+ }
32
34
33
35
if ( ! reset ) {
34
36
// TODO - Protect this under a debug mode?
You can’t perform that action at this time.
0 commit comments