Skip to content

Commit

Permalink
Set isConnectedToInternet with value coming from @react-native-commun…
Browse files Browse the repository at this point in the history
…ity/netinfo
  • Loading branch information
romin-halltari committed Nov 28, 2023
1 parent c2bdbd6 commit 08781b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useState, useCallback, useMemo } from 'react';
import React, { useState, useCallback, useMemo, useEffect } from 'react';
import { Linking, StyleSheet, View } from 'react-native';
import { WebView } from 'react-native-webview';
import { SafeAreaView } from 'react-native-safe-area-context';
import { ViewController, createModalNotReadyError } from '@magic-sdk/provider';
import { MagicMessageEvent } from '@magic-sdk/types';
import { isTypedArray } from 'lodash';
import Global = NodeJS.Global;
import { useInternetConnection } from './hooks';

const MAGIC_PAYLOAD_FLAG_TYPED_ARRAY = 'MAGIC_PAYLOAD_FLAG_TYPED_ARRAY';
const OPEN_IN_DEVICE_BROWSER = 'open_in_device_browser';
Expand Down Expand Up @@ -79,6 +80,11 @@ export class ReactNativeWebViewController extends ViewController {
/* istanbul ignore next */
public Relayer: React.FC<{ backgroundColor?: string }> = (backgroundColor) => {
const [show, setShow] = useState(false);
const isConnected = useInternetConnection();

useEffect(() => {
this.isConnectedToInternet = isConnected;
}, [isConnected]);

/**
* Saves a reference to the underlying `<WebView>` node so we can interact
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useState, useCallback, useMemo } from 'react';
import React, { useState, useCallback, useMemo, useEffect } from 'react';
import { Linking, StyleSheet, View } from 'react-native';
import { WebView } from 'react-native-webview';
import { SafeAreaView } from 'react-native-safe-area-context';
import { ViewController, createModalNotReadyError } from '@magic-sdk/provider';
import { MagicMessageEvent } from '@magic-sdk/types';
import { isTypedArray } from 'lodash';
import Global = NodeJS.Global;
import { useInternetConnection } from './hooks';

const MAGIC_PAYLOAD_FLAG_TYPED_ARRAY = 'MAGIC_PAYLOAD_FLAG_TYPED_ARRAY';
const OPEN_IN_DEVICE_BROWSER = 'open_in_device_browser';
Expand Down Expand Up @@ -79,6 +80,11 @@ export class ReactNativeWebViewController extends ViewController {
/* istanbul ignore next */
public Relayer: React.FC<{ backgroundColor?: string }> = ({ backgroundColor }) => {
const [show, setShow] = useState(false);
const isConnected = useInternetConnection();

useEffect(() => {
this.isConnectedToInternet = isConnected;
}, [isConnected]);

/**
* Saves a reference to the underlying `<WebView>` node so we can interact
Expand Down

0 comments on commit 08781b7

Please sign in to comment.