-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React 16.13 #1145
React 16.13 #1145
Changes from 19 commits
ddb3f9b
f187c0c
7ee674b
f9b180f
67e18e7
d811a44
8b52d41
dc46d06
bf2650d
a4a015f
1fe5fad
6102887
602ac9e
cfeba32
3d5942b
942975b
517cf28
b341ef4
c9ea949
f6ea5e2
4496eba
eed7b52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,7 @@ | |
"no-new-wrappers": ["error"], | ||
"no-param-reassign": ["error"], | ||
"no-process-env": ["warn"], | ||
"no-prototype-builtins": ["off"], | ||
"no-proto": ["error"], | ||
"no-redeclare": ["error"], | ||
"no-return-assign": ["error"], | ||
|
@@ -141,7 +142,7 @@ | |
}], | ||
"no-magic-numbers": ["error", { | ||
"ignoreArrayIndexes": true, | ||
"ignore": [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100, 10, 16, 0.5, 25] | ||
"ignore": [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100, 10, 16, 0.5, 25, 200, 500] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some xhr return codes |
||
}], | ||
"no-underscore-dangle": ["off"], | ||
"no-useless-escape": ["off"] | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import {connect} from 'react-redux'; | ||
import {includes, isEmpty, isNil} from 'ramda'; | ||
import React, {Component} from 'react'; | ||
import React, {useEffect, useState} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import TreeContainer from './TreeContainer'; | ||
import GlobalErrorContainer from './components/error/GlobalErrorContainer.react'; | ||
|
@@ -18,23 +18,10 @@ import {STATUS} from './constants/constants'; | |
/** | ||
* Fire off API calls for initialization | ||
*/ | ||
class UnconnectedContainer extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.initialization = this.initialization.bind(this); | ||
this.state = { | ||
errorLoading: false, | ||
}; | ||
} | ||
componentDidMount() { | ||
this.initialization(this.props); | ||
} | ||
|
||
componentWillReceiveProps(props) { | ||
this.initialization(props); | ||
} | ||
const UnconnectedContainer = props => { | ||
const [errorLoading, setErrorLoading] = useState(false); | ||
|
||
initialization(props) { | ||
useEffect(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rewriting the ApiController as a functional component allows the use of |
||
const { | ||
appLifecycle, | ||
dependenciesRequest, | ||
|
@@ -60,8 +47,16 @@ class UnconnectedContainer extends Component { | |
} | ||
|
||
if (isEmpty(dependenciesRequest)) { | ||
dispatch( | ||
apiThunk('_dash-dependencies', 'GET', 'dependenciesRequest') | ||
setTimeout( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove setTimeout (experiment) |
||
() => | ||
dispatch( | ||
apiThunk( | ||
'_dash-dependencies', | ||
'GET', | ||
'dependenciesRequest' | ||
) | ||
), | ||
0 | ||
); | ||
} else if ( | ||
dependenciesRequest.status === STATUS.OK && | ||
|
@@ -81,67 +76,57 @@ class UnconnectedContainer extends Component { | |
// Hasn't already hydrated | ||
appLifecycle === getAppState('STARTED') | ||
) { | ||
let errorLoading = false; | ||
let error = false; | ||
try { | ||
dispatch(hydrateInitialOutputs()); | ||
} catch (err) { | ||
errorLoading = true; | ||
error = true; | ||
} finally { | ||
this.setState(state => | ||
state.errorLoading !== errorLoading ? {errorLoading} : null | ||
); | ||
setErrorLoading(error); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
render() { | ||
const { | ||
appLifecycle, | ||
dependenciesRequest, | ||
layoutRequest, | ||
layout, | ||
config, | ||
} = this.props; | ||
|
||
const {errorLoading} = this.state; | ||
const { | ||
appLifecycle, | ||
dependenciesRequest, | ||
layoutRequest, | ||
layout, | ||
config, | ||
} = props; | ||
|
||
if ( | ||
layoutRequest.status && | ||
!includes(layoutRequest.status, [STATUS.OK, 'loading']) | ||
) { | ||
return <div className="_dash-error">Error loading layout</div>; | ||
} else if ( | ||
errorLoading || | ||
(dependenciesRequest.status && | ||
!includes(dependenciesRequest.status, [STATUS.OK, 'loading'])) | ||
) { | ||
return ( | ||
<div className="_dash-error">Error loading dependencies</div> | ||
); | ||
} else if ( | ||
appLifecycle === getAppState('HYDRATED') && | ||
config.ui === true | ||
) { | ||
return ( | ||
<GlobalErrorContainer> | ||
<TreeContainer | ||
_dashprivate_layout={layout} | ||
_dashprivate_path={[]} | ||
/> | ||
</GlobalErrorContainer> | ||
); | ||
} else if (appLifecycle === getAppState('HYDRATED')) { | ||
return ( | ||
if ( | ||
layoutRequest.status && | ||
!includes(layoutRequest.status, [STATUS.OK, 'loading']) | ||
) { | ||
return <div className="_dash-error">Error loading layout</div>; | ||
} else if ( | ||
errorLoading || | ||
(dependenciesRequest.status && | ||
!includes(dependenciesRequest.status, [STATUS.OK, 'loading'])) | ||
) { | ||
return <div className="_dash-error">Error loading dependencies</div>; | ||
} else if (appLifecycle === getAppState('HYDRATED') && config.ui === true) { | ||
return ( | ||
<GlobalErrorContainer> | ||
<TreeContainer | ||
_dashprivate_layout={layout} | ||
_dashprivate_path={[]} | ||
/> | ||
); | ||
} | ||
|
||
return <div className="_dash-loading">Loading...</div>; | ||
</GlobalErrorContainer> | ||
); | ||
} else if (appLifecycle === getAppState('HYDRATED')) { | ||
return ( | ||
<TreeContainer | ||
_dashprivate_layout={layout} | ||
_dashprivate_path={[]} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
return <div className="_dash-loading">Loading...</div>; | ||
}; | ||
|
||
UnconnectedContainer.propTypes = { | ||
appLifecycle: PropTypes.oneOf([ | ||
getAppState('STARTED'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/* eslint-disable no-undef,react/no-did-update-set-state,no-magic-numbers */ | ||
import { | ||
comparator, | ||
equals, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
myObject.hasOwnProperty(...)
is fine