Skip to content

Commit

Permalink
Merge pull request #70 from at88mph/refresh-fix
Browse files Browse the repository at this point in the history
Replace componentWillReceiveProps unsafe function.
  • Loading branch information
at88mph authored Jul 10, 2024
2 parents 42e48a5 + e6e0d3d commit 7cbc477
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 17 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# tags with and without build number so operators use the versioned
# tag but we always keep a timestamped tag in case a semantic tag gets
# replaced accidentally
VER=0.2.5
VER=0.2.6
TAGS="${VER} ${VER}-$(date -u +"%Y%m%dT%H%M%S")"
unset VER
12 changes: 10 additions & 2 deletions src/react/SciencePortalConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ class SciencePortalConfirm extends React.Component {
this.onConfirm = this.onConfirm.bind(this);
}

componentWillReceiveProps(nextProps) {
this.setState(nextProps)
static getDerivedStateFromProps(nextProps, _prevState) {
return nextProps;
}

componentDidUpdate(nextProps) {
if (this.props !== nextProps) {
this.setState({
nextProps
});
}
}

onClose(event) {
Expand Down
12 changes: 9 additions & 3 deletions src/react/SciencePortalForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ class SciencePortalForm extends React.Component {
selectedRAM : this.state.fData.contextData.defaultRAM
});
this.state.fData.resetHandler();

}

componentWillReceiveProps(nextProps) {
this.setState({ fData: nextProps.fData });
static getDerivedStateFromProps(nextProps, _prevState) {
return { fData: nextProps.fData };
}

componentDidUpdate(nextProps) {
if (this.props.fData !== nextProps.fData) {
this.setState({
fData: nextProps.fData
});
}
}

renderPopover(headerText, bodyText) {
return <OverlayTrigger
Expand Down
12 changes: 10 additions & 2 deletions src/react/SciencePortalModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ class SciencePortalModal extends React.Component {
this.setState({isOpen: false});
}

componentWillReceiveProps(nextProps) {
this.setState({modalData: nextProps.modalData});
static getDerivedStateFromProps(nextProps, _prevState) {
return { modalData: nextProps.modalData };
}

componentDidUpdate(nextProps) {
if (this.props.modalData !== nextProps.modalData) {
this.setState({
modalData: nextProps.modalData
});
}
}

handleReload = () => {
Expand Down
12 changes: 10 additions & 2 deletions src/react/canfar/CanfarLoginModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ class CanfarLoginModal extends React.Component {
this.setState({ isOpen: false });
}

componentWillReceiveProps(nextProps) {
this.setState(nextProps);
static getDerivedStateFromProps(nextProps, _prevState) {
return nextProps;
}

componentDidUpdate(nextProps) {
if (this.props !== nextProps) {
this.setState({
nextProps
});
}
}

closeModal = () => this.setState({ isOpen: false });
Expand Down
13 changes: 10 additions & 3 deletions src/react/canfar/CanfarNavbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ class CanfarNavbar extends React.Component {

// This function allows data to move through and re-render
// children using this data
componentWillReceiveProps(nextProps) {
this.setState(nextProps);
static getDerivedStateFromProps(nextProps, _prevState) {
return nextProps;
}

componentDidUpdate(nextProps) {
if (this.props !== nextProps) {
this.setState({
nextProps
});
}
}

renderButton() {
return (
<Button size="sm" variant="outline-primary">{this.state.authenticatedUser}<span className="sp-buffer-span-left"><FontAwesomeIcon icon={faCaretDown} /></span></Button>
Expand Down
12 changes: 10 additions & 2 deletions src/react/src/SRCLoginModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ class SRCLoginModal extends React.Component {
this.setState({ isOpen: false });
}

componentWillReceiveProps(nextProps) {
this.setState(nextProps);
static getDerivedStateFromProps(nextProps, _prevState) {
return nextProps;
}

componentDidUpdate(nextProps) {
if (this.props !== nextProps) {
this.setState({
nextProps
});
}
}

closeModal = () => this.setState({ isOpen: false });
Expand Down
12 changes: 10 additions & 2 deletions src/react/src/SRCNavbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ class SRCNavbar extends React.Component {

// This function allows data to move through and re-render
// children using this data
componentWillReceiveProps(nextProps) {
this.setState(nextProps);
static getDerivedStateFromProps(nextProps, _prevState) {
return nextProps;
}

componentDidUpdate(nextProps) {
if (this.props !== nextProps) {
this.setState({
nextProps
});
}
}

render() {
Expand Down

0 comments on commit 7cbc477

Please sign in to comment.