@@ -28,19 +28,10 @@ const styles = createStyleSheet({
28
28
29
29
type Props = $ReadOnly < { || } > ;
30
30
31
- /**
32
- * Shows a notice if the app is working in offline mode.
33
- *
34
- * Shows a different notice if we've taken longer than we expect to
35
- * determine Internet reachability. IOW, if the user sees this, there's a
36
- * bug.
37
- *
38
- * Shows nothing if the Internet is reachable.
39
- */
40
- export default function OfflineNotice ( props : Props ) : Node {
31
+ function useShouldShowUncertaintyNotice ( ) {
41
32
const isOnline = useGlobalSelector ( state => getGlobalSession ( state ) . isOnline ) ;
42
33
43
- const shouldShowUncertaintyNotice = useHasStayedTrueForMs (
34
+ const result = useHasStayedTrueForMs (
44
35
// See note in `SessionState` for what this means.
45
36
isOnline === null ,
46
37
@@ -59,7 +50,7 @@ export default function OfflineNotice(props: Props): Node {
59
50
) ;
60
51
61
52
useEffect ( ( ) => {
62
- if ( shouldShowUncertaintyNotice ) {
53
+ if ( result ) {
63
54
NetInfo . fetch ( ) . then ( state => {
64
55
logging . warn (
65
56
'Failed to determine Internet reachability in a reasonable time' ,
@@ -71,7 +62,23 @@ export default function OfflineNotice(props: Props): Node {
71
62
) ;
72
63
} ) ;
73
64
}
74
- } , [ shouldShowUncertaintyNotice ] ) ;
65
+ } , [ result ] ) ;
66
+
67
+ return result ;
68
+ }
69
+
70
+ /**
71
+ * Shows a notice if the app is working in offline mode.
72
+ *
73
+ * Shows a different notice if we've taken longer than we expect to
74
+ * determine Internet reachability. IOW, if the user sees this, there's a
75
+ * bug.
76
+ *
77
+ * Shows nothing if the Internet is reachable.
78
+ */
79
+ export default function OfflineNotice ( props : Props ) : Node {
80
+ const isOnline = useGlobalSelector ( state => getGlobalSession ( state ) . isOnline ) ;
81
+ const shouldShowUncertaintyNotice = useShouldShowUncertaintyNotice ( ) ;
75
82
76
83
if ( shouldShowUncertaintyNotice ) {
77
84
return (
0 commit comments