Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ac39d61

Browse files
committed
warn of data loss on reloading registration page
1 parent 4a38cbd commit ac39d61

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/components/views/auth/AuthBody.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ limitations under the License.
1717
import React from 'react';
1818

1919
export default class AuthBody extends React.PureComponent {
20+
componentDidMount() {
21+
const unloadCallback = (event) => {
22+
event.preventDefault();
23+
event.returnValue = "";
24+
return "";
25+
};
26+
window.addEventListener("beforeunload", unloadCallback);
27+
return () => window.removeEventListener("beforeunload", unloadCallback);
28+
}
29+
2030
public render(): React.ReactNode {
2131
return <div className="mx_AuthBody">
2232
{ this.props.children }

0 commit comments

Comments
 (0)