react beforeunload react navive

Solutions on MaxInterview for react beforeunload react navive by the best coders in the world

showing results for - "react beforeunload react navive"
Mats
30 Mar 2017
1import { Beforeunload } from 'react-beforeunload';
2
3class Example extends React.Component {
4  state = { value: '' };
5
6  render() {
7    return (
8      <>
9        {value !== '' && (
10          <Beforeunload onBeforeunload={(event) => event.preventDefault()} />
11        )}
12        <input
13          onChange={(event) => this.setState({ value: event.target.value })}
14          value={this.state.value}
15        />
16      </>
17    );
18  }
19}