-
-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AppNavigator: Stop changing what we pass for
Stack.Screen
s' `compon…
…ent`. Before, whenever `AppNavigator` was called, a new value was passed to these `Stack.Screen`s as `component`. That's because `withHaveServerDataGate` returns a fresh component made by react-redux's `connect`. We found with a bisect that something in a80b4e8 was causing #4723. Here, we stop letting that value change, and we see that it fixes that issue. Alternatively, we might have put the `withHaveServerDataGate` call in the same file as `MainTabsScreen`, etc. -- after all, that's our usual practice for higher-order components. But the choice to put it in AppNavigator (in a80b4e8 and f53d4f6) was intentional: we wanted to make it easy to scan through and spot any that should be treated with `withHaveServerDataGate` and aren't. We considered `useMemo` instead of `useRef`, but the documentation [1] cautions against that for cases like these: > **You may rely on useMemo as a performance optimization, not as a > semantic guarantee.** In the future, React may choose to “forget” > some previously memoized values and recalculate them on next > render, e.g. to free memory for offscreen components. Write your > code so that it still works without `useMemo` — and then add it to > optimize performance. So, use `useRef`. [1] https://reactjs.org/docs/hooks-reference.html#usememo Co-authored-by: Greg Price <greg@zulip.com> Fixes: #4723
- Loading branch information
1 parent
61b136d
commit 98d19b8
Showing
2 changed files
with
44 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters