React-Beforuunload React Navive
import { Beforeunload } from 'react-beforeunload';
class Example extends React.Component {
state = { value: '' };
render() {
return (
<>
{value !== '' && (
<Beforeunload onBeforeunload={(event) => event.preventDefault()} />
)}
<input
onChange={(event) => this.setState({ value: event.target.value })}
value={this.state.value}
/>
</>
);
}
}
anonimus_desu