Skip to content
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

Replace componentWillReceiveProps unsafe function. #70

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading