na guia fechada react web nativo
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