mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-07 15:08:24 +00:00
Patch: "Reloading the registration page should warn about data loss" (#8377)
This commit is contained in:
@@ -139,8 +139,21 @@ export default class Registration extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.replaceClient(this.props.serverConfig);
|
this.replaceClient(this.props.serverConfig);
|
||||||
|
//triggers a confirmation dialog for data loss before page unloads/refreshes
|
||||||
|
window.addEventListener("beforeunload", this.unloadCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
window.removeEventListener("beforeunload", this.unloadCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
private unloadCallback = (event: BeforeUnloadEvent) => {
|
||||||
|
if (this.state.doingUIAuth) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.returnValue = "";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
// TODO: [REACT-WARNING] Replace with appropriate lifecycle event
|
// TODO: [REACT-WARNING] Replace with appropriate lifecycle event
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
UNSAFE_componentWillReceiveProps(newProps) {
|
UNSAFE_componentWillReceiveProps(newProps) {
|
||||||
|
|||||||
Reference in New Issue
Block a user