expo-dev-launcher 2.4.11 → 2.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- import { useFocusEffect } from '@react-navigation/core';
2
1
  import {
3
2
  Heading,
4
3
  Text,
@@ -38,12 +37,18 @@ import { useUpdatesConfig } from '../providers/UpdatesConfigProvider';
38
37
  import { DevSession } from '../types';
39
38
 
40
39
  export type HomeScreenProps = {
40
+ fetchOnMount?: boolean;
41
41
  pollInterval?: number;
42
42
  pollAmount?: number;
43
43
  navigation?: any;
44
44
  };
45
45
 
46
- export function HomeScreen({ pollInterval = 1000, pollAmount = 5, navigation }: HomeScreenProps) {
46
+ export function HomeScreen({
47
+ fetchOnMount = false,
48
+ pollInterval = 1000,
49
+ pollAmount = 5,
50
+ navigation,
51
+ }: HomeScreenProps) {
47
52
  const modalStack = useModalStack();
48
53
  const [inputValue, setInputValue] = React.useState('');
49
54
  const [loadingUrl, setLoadingUrl] = React.useState('');
@@ -54,14 +59,13 @@ export function HomeScreen({ pollInterval = 1000, pollAmount = 5, navigation }:
54
59
 
55
60
  const crashReport = useCrashReport();
56
61
 
57
- const hasDevSessions = devSessions?.length > 0;
58
- useFocusEffect(
59
- React.useCallback(() => {
60
- if (!hasDevSessions) {
61
- pollAsync({ pollAmount, pollInterval });
62
- }
63
- }, [hasDevSessions, pollAmount, pollInterval])
64
- );
62
+ const initialDevSessionData = React.useRef(devSessions);
63
+
64
+ React.useEffect(() => {
65
+ if (initialDevSessionData.current.length === 0 && fetchOnMount) {
66
+ pollAsync({ pollAmount, pollInterval });
67
+ }
68
+ }, [fetchOnMount, pollInterval, pollAmount, pollAsync]);
65
69
 
66
70
  const onLoadUrl = async (url: string) => {
67
71
  setLoadingUrl(url);
@@ -137,7 +141,7 @@ export function HomeScreen({ pollInterval = 1000, pollAmount = 5, navigation }:
137
141
 
138
142
  <Spacer.Horizontal />
139
143
 
140
- {devSessions?.length > 0 && (
144
+ {devSessions.length > 0 && (
141
145
  <Button.FadeOnPressContainer
142
146
  bg="ghost"
143
147
  rounded="full"
@@ -153,7 +157,7 @@ export function HomeScreen({ pollInterval = 1000, pollAmount = 5, navigation }:
153
157
 
154
158
  <View px="medium">
155
159
  <View>
156
- {devSessions?.length === 0 && (
160
+ {devSessions.length === 0 && (
157
161
  <>
158
162
  <View padding="medium" bg="default" roundedTop="large">
159
163
  <Text>Start a local development server with:</Text>