14 | { this.state.connecting ?
Waiting response from RN...
: null }
15 | { this.state.connected ?
16 |
Connected to RN 🎉
:
17 | !this.state.connecting ?
18 |
:
19 | null
20 | }
21 |
22 | );
23 | }
24 |
25 | connect = () => {
26 | this.setState({ connecting: true });
27 |
28 | connectToRemote()
29 | .then(remote => {
30 | this.remote = remote;
31 |
32 | this.setState({
33 | connected: true,
34 | connecting: false,
35 | });
36 | })
37 | .catch(err => console.log(err));
38 | }
39 | }
40 |
41 | render(
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
{ this.state.message ? this.state.message : null }
43 |
44 | );
45 | }
46 |
47 | sendText = () => {
48 | this.remote.send('hello');
49 | }
50 |
51 | sendJSON = () => {
52 | this.remote.sendJSON({
53 | payload: 'hello'
54 | });
55 | }
56 |
57 | emitEvent = () => {
58 | this.remote.emit('greetingFromWebview', {
59 | payload: 'hello'
60 | });
61 | }
62 | }
63 |
64 | render(