Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

Why is my react native app re-rendering every time I bring it to the foreground in App.tsx?

$
0
0

apologies in advance if this is a silly. I'm only a few months into React Native.

I'm a little confused why my app is re-rendering in App.tsx every time I bring the app from the background to the foreground.

Here is the code for App.tsx.

import React, { useState, useEffect } from 'react';import * as Sentry from 'sentry-expo'; import 'react-native-gesture-handler';import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client';import { UserIdContextProvider } from './app/utils/context/UserIdContext'; import {decode, encode} from 'base-64'import { WebSocketLink } from 'apollo-link-ws';import * as Segment from 'expo-analytics-segment';import { DoormanProvider, AuthFlow, AuthGate  } from 'react-native-doorman'; import { ActivityIndicator } from 'react-native'import AppNavigator from './AppNavigator';import { colors } from './app/styles/colors';import { withOta } from './app/hoc/with-ota';import firebaseApp from './app/utils/firebase/fbConfig';const iosWriteKey = [IOS_KEY];const androidWriteKey = [ANDROID_KEY];const graphqlEndpoint = [ENDPOINT];export default function App() {  console.log("rerendering App");   useEffect(() => {    if (!global.btoa) {      global.btoa = encode;      }      if (!global.atob) {      global.atob = decode;      }      Sentry.init({        dsn: [DSN],        enableInExpoDevelopment: true,        debug: true      });   }, []);  return(<AuthenticatedApp  />  ) };

When I put the app in the background and then bring it back, the console log produces "rerendering App". I thought nothing would re-render, at first glance. Is there something that I'm missing?


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>