Commit e7eae179 authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH

[js] refactor out usage of deprecated lifecycle funcs

parent 872a5921
......@@ -87,12 +87,14 @@ class CacheInput extends React.Component<Props, State>{
this.updateValidity(this.state.cache);
}
// if the parent's model changes, reset input
componentWillReceiveProps (nextProps: any) {
this.setState({
cache: (nextProps.value),
});
this.clearTimer();
// if the parent's model (the props) changes, reset input
componentDidUpdate = (prevProps: Props) => {
if(this.props.value !== prevProps.value){
this.setState({
cache: (this.props.value),
});
this.clearTimer();
}
}
// gets the validity info of an input string given a curr val
......
......@@ -85,11 +85,13 @@ export class NewEntityModal extends React.Component<Props, State> {
numSegs: nameSegmentsForEntity(this.props.entity),
}
componentWillReceiveProps = (newProps: Props) => {
this.setState({
nameSegs: getStartNameSegs(newProps.copyObj, newProps.data.map(d => d.name), newProps.entity, newProps.nameOrVersion),
numSegs: nameSegmentsForEntity(newProps.entity),
});
componentDidUpdate = (prevProps: Props) => {
if(this.props !== prevProps){
this.setState({
nameSegs: getStartNameSegs(this.props.copyObj, this.props.data.map(d => d.name), this.props.entity, this.props.nameOrVersion),
numSegs: nameSegmentsForEntity(this.props.entity),
});
}
}
titleStr = () => `New ${ this.props.entity }: "${ this.getNameString() }"`;
......
......@@ -54,8 +54,10 @@ class SearchBar extends React.PureComponent<Props, State> {
this.updateFuseInstance();
}
componentWillReceiveProps = (nextProps: Props) => {
this.updateFuseInstance(nextProps.data);
componentDidUpdate = (prevProps: Props) => {
if(this.props.data !== prevProps.data){
this.updateFuseInstance(this.props.data);
}
}
updateFuseInstance = (data: BeatObject[] = this.props.data) => {
......
......@@ -82,10 +82,12 @@ export class AlgorithmEditor extends React.Component<Props, State> {
}
// if the data changes behind the scenes, update the editor with these changes
UNSAFE_componentWillReceiveProps (nextProps: Props) {
this.setState({
validity: this.getValidity(nextProps.data, nextProps.algorithms),
});
componentDidUpdate = (prevProps: Props) => {
if(this.props !== prevProps){
this.setState({
validity: this.getValidity(this.props.data, this.props.algorithms),
});
}
}
// get the result types (analyzer result types are restricted to a subset of all available types)
......
......@@ -87,8 +87,10 @@ class InsertObjectModal extends React.PureComponent<Props, State> {
this.updateFuseInstance();
}
componentWillReceiveProps = (nextProps: Props) => {
this.updateFuseInstance(nextProps[this.state.searchFilter]);
componentDidUpdate = (prevProps: Props) => {
if(this.props[this.state.searchFilter] !== prevProps[this.state.searchFilter]){
this.updateFuseInstance(this.props[this.state.searchFilter]);
}
}
updateFuseInstance = (data: any[] = this.props[this.state.searchFilter]) => {
......
......@@ -34,8 +34,10 @@ class RenameGroupModal extends React.PureComponent<Props, State> {
newName: this.props.currentName,
}
componentWillReceiveProps = (nextProps: Props) => {
this.setState({ newName: nextProps.currentName });
componentDidUpdate = (prevProps: Props) => {
if(this.props.currentName !== prevProps.currentName){
this.setState({ newName: this.props.currentName });
}
}
validateFunc = (str: string) => {
......
......@@ -134,15 +134,6 @@ export class ToolchainEditor extends React.PureComponent<Props, State> {
},
}
// if the toolchain was updated, reset specific state fields
UNSAFE_componentWillReceiveProps = (nextProps: Props) => {
/*
this.setState({
history: generateNewHistory(this.state),
});
*/
}
// helper to set the contents (this.props.data.contents) object
setContents = (newContents: any) => {
this.setState((prevState, props) => ({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment