11import { batch , connect } from 'react-redux' ;
22import { includes , isEmpty } from 'ramda' ;
3- import React , {
4- useEffect ,
5- useRef ,
6- useState ,
7- createContext ,
8- useCallback
9- } from 'react' ;
3+ import React , { useEffect , useRef , useState , createContext } from 'react' ;
104import PropTypes from 'prop-types' ;
115import TreeContainer from './TreeContainer' ;
126import GlobalErrorContainer from './components/error/GlobalErrorContainer.react' ;
@@ -27,7 +21,6 @@ import {getAppState} from './reducers/constants';
2721import { STATUS } from './constants/constants' ;
2822import { getLoadingState , getLoadingHash } from './utils/TreeContainer' ;
2923import wait from './utils/wait' ;
30- import LibraryManager from './libraries/LibraryManager' ;
3124
3225export const DashContext = createContext ( { } ) ;
3326
@@ -53,10 +46,6 @@ const UnconnectedContainer = props => {
5346 if ( ! events . current ) {
5447 events . current = new EventEmitter ( ) ;
5548 }
56-
57- const [ libraryReady , setLibraryReady ] = useState ( false ) ;
58- const onLibraryReady = useCallback ( ( ) => setLibraryReady ( true ) , [ ] ) ;
59-
6049 const renderedTree = useRef ( false ) ;
6150
6251 const propsRef = useRef ( { } ) ;
@@ -71,9 +60,7 @@ const UnconnectedContainer = props => {
7160 } )
7261 } ) ;
7362
74- useEffect (
75- storeEffect . bind ( null , props , events , setErrorLoading , libraryReady )
76- ) ;
63+ useEffect ( storeEffect . bind ( null , props , events , setErrorLoading ) ) ;
7764
7865 useEffect ( ( ) => {
7966 if ( renderedTree . current ) {
@@ -130,23 +117,14 @@ const UnconnectedContainer = props => {
130117 content = < div className = '_dash-loading' > Loading...</ div > ;
131118 }
132119
133- return (
134- < LibraryManager
135- requests_pathname_prefix = { config . requests_pathname_prefix }
136- onReady = { onLibraryReady }
137- ready = { libraryReady }
138- layout = { layoutRequest && layoutRequest . content }
139- >
140- { config && config . ui === true ? (
141- < GlobalErrorContainer > { content } </ GlobalErrorContainer >
142- ) : (
143- content
144- ) }
145- </ LibraryManager >
120+ return config && config . ui === true ? (
121+ < GlobalErrorContainer > { content } </ GlobalErrorContainer >
122+ ) : (
123+ content
146124 ) ;
147125} ;
148126
149- function storeEffect ( props , events , setErrorLoading , libraryReady ) {
127+ function storeEffect ( props , events , setErrorLoading ) {
150128 const {
151129 appLifecycle,
152130 dependenciesRequest,
@@ -165,7 +143,7 @@ function storeEffect(props, events, setErrorLoading, libraryReady) {
165143 }
166144 dispatch ( apiThunk ( '_dash-layout' , 'GET' , 'layoutRequest' ) ) ;
167145 } else if ( layoutRequest . status === STATUS . OK ) {
168- if ( isEmpty ( layout ) && libraryReady ) {
146+ if ( isEmpty ( layout ) ) {
169147 if ( typeof hooks . layout_post === 'function' ) {
170148 hooks . layout_post ( layoutRequest . content ) ;
171149 }
@@ -208,8 +186,7 @@ function storeEffect(props, events, setErrorLoading, libraryReady) {
208186 layoutRequest . status === STATUS . OK &&
209187 ! isEmpty ( layout ) &&
210188 // Hasn't already hydrated
211- appLifecycle === getAppState ( 'STARTED' ) &&
212- libraryReady
189+ appLifecycle === getAppState ( 'STARTED' )
213190 ) {
214191 let hasError = false ;
215192 try {
@@ -258,8 +235,7 @@ const Container = connect(
258235 graphs : state . graphs ,
259236 history : state . history ,
260237 error : state . error ,
261- config : state . config ,
262- paths : state . paths
238+ config : state . config
263239 } ) ,
264240 dispatch => ( { dispatch} )
265241) ( UnconnectedContainer ) ;
0 commit comments