about summary refs log tree commit diff
path: root/src/view/com/pager/PagerWithHeader.tsx
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-02-09 05:00:50 +0000
committerGitHub <noreply@github.com>2024-02-08 21:00:50 -0800
commitd36b91fe67225a9d3c79c8eeb3c80f6a72e9f73f (patch)
tree965fb97bd9508afffdf66a4d2e951f57bd566f1e /src/view/com/pager/PagerWithHeader.tsx
parent0d00c7d8516d2e4b736f5a2eaa679dbcce2cb71c (diff)
downloadvoidsky-d36b91fe67225a9d3c79c8eeb3c80f6a72e9f73f.tar.zst
Fix flashes and jumps when opening profile (#2815)
* Don't reset the tree when profile loads fully

* Give avatars a background color like placeholders

* Prevent jumps due to rich text resolving

* Rm log

* Rm unused
Diffstat (limited to 'src/view/com/pager/PagerWithHeader.tsx')
-rw-r--r--src/view/com/pager/PagerWithHeader.tsx22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/view/com/pager/PagerWithHeader.tsx b/src/view/com/pager/PagerWithHeader.tsx
index 7e9ed24db..31abc1ab7 100644
--- a/src/view/com/pager/PagerWithHeader.tsx
+++ b/src/view/com/pager/PagerWithHeader.tsx
@@ -61,25 +61,21 @@ export const PagerWithHeader = React.forwardRef<PagerRef, PagerWithHeaderProps>(
     const headerHeight = headerOnlyHeight + tabBarHeight
 
     // capture the header bar sizing
-    const onTabBarLayout = React.useCallback(
-      (evt: LayoutChangeEvent) => {
-        const height = evt.nativeEvent.layout.height
-        if (height > 0) {
-          // The rounding is necessary to prevent jumps on iOS
-          setTabBarHeight(Math.round(height))
-        }
-      },
-      [setTabBarHeight],
-    )
-    const onHeaderOnlyLayout = React.useCallback(
+    const onTabBarLayout = useNonReactiveCallback((evt: LayoutChangeEvent) => {
+      const height = evt.nativeEvent.layout.height
+      if (height > 0) {
+        // The rounding is necessary to prevent jumps on iOS
+        setTabBarHeight(Math.round(height))
+      }
+    })
+    const onHeaderOnlyLayout = useNonReactiveCallback(
       (evt: LayoutChangeEvent) => {
         const height = evt.nativeEvent.layout.height
-        if (height > 0) {
+        if (height > 0 && isHeaderReady) {
           // The rounding is necessary to prevent jumps on iOS
           setHeaderOnlyHeight(Math.round(height))
         }
       },
-      [setHeaderOnlyHeight],
     )
 
     const renderTabBar = React.useCallback(