@@ -29,7 +29,7 @@ import { getAuth, getCaughtUpForNarrow } from '../selectors';
2929import { showErrorAlert } from '../utils/info' ;
3030import { TranslationContext } from '../boot/TranslationProvider' ;
3131import * as api from '../api' ;
32- import { useEdgeTriggeredEffect } from '../reactUtils' ;
32+ import { useConditionalEffect } from '../reactUtils' ;
3333
3434type Props = $ReadOnly < { |
3535 navigation : AppNavigationProp < 'chat' > ,
@@ -71,9 +71,9 @@ const useMessagesWithFetch = args => {
7171 // like using instance variables in class components:
7272 // https://reactjs.org/docs/hooks-faq.html#is-there-something-like-instance-variables
7373 const shouldFetchWhenNextFocused = React . useRef < boolean > ( false ) ;
74- const scheduleFetch = ( ) => {
74+ const scheduleFetch = useCallback ( ( ) => {
7575 shouldFetchWhenNextFocused . current = true ;
76- } ;
76+ } , [ ] ) ;
7777
7878 const [ fetchError , setFetchError ] = React . useState < mixed > ( null ) ;
7979
@@ -92,7 +92,7 @@ const useMessagesWithFetch = args => {
9292 if ( eventQueueId !== null ) {
9393 scheduleFetch ( ) ;
9494 }
95- } , [ eventQueueId ] ) ;
95+ } , [ eventQueueId , scheduleFetch ] ) ;
9696
9797 // If we stop having any data at all about the messages in this narrow --
9898 // we don't know any, and nor do we know if there are some -- then
@@ -104,7 +104,7 @@ const useMessagesWithFetch = args => {
104104 // isFetching false, even though the fetch effect will cause a rerender
105105 // with isFetching true. It'd be nice to avoid that.
106106 const nothingKnown = messages . length === 0 && ! caughtUp . older && ! caughtUp . newer ;
107- useEdgeTriggeredEffect ( scheduleFetch , nothingKnown , true ) ;
107+ useConditionalEffect ( scheduleFetch , nothingKnown ) ;
108108
109109 // On first mount, fetch. (This also makes a fetch no longer scheduled,
110110 // so the if-scheduled fetch below doesn't also fire.)
0 commit comments