From c8745a9ab0a99ac3cf484e00760e72d1e9f28dfc Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 12 Dec 2024 04:20:22 +0000 Subject: Cache Reanimated worklets (#7068) * Undo perf hackfix * Bump Reanimated to include https://github.com/software-mansion/react-native-reanimated/pull/6758 * Bump to 3.17.0-nightly-20241211-17e89ca24 --- src/view/com/util/MainScrollProvider.tsx | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/view/com/util/MainScrollProvider.tsx b/src/view/com/util/MainScrollProvider.tsx index c1293a83c..e2538eaab 100644 --- a/src/view/com/util/MainScrollProvider.tsx +++ b/src/view/com/util/MainScrollProvider.tsx @@ -1,11 +1,6 @@ import React, {useCallback, useEffect} from 'react' import {NativeScrollEvent} from 'react-native' -import { - interpolate, - makeMutable, - useSharedValue, - withSpring, -} from 'react-native-reanimated' +import {interpolate, useSharedValue, withSpring} from 'react-native-reanimated' import EventEmitter from 'eventemitter3' import {ScrollProvider} from '#/lib/ScrollContext' @@ -20,18 +15,6 @@ function clamp(num: number, min: number, max: number) { return Math.min(Math.max(num, min), max) } -const V0 = makeMutable( - withSpring(0, { - overshootClamping: true, - }), -) - -const V1 = makeMutable( - withSpring(1, { - overshootClamping: true, - }), -) - export function MainScrollProvider({children}: {children: React.ReactNode}) { const {headerHeight} = useShellLayout() const {headerMode} = useMinimalShellMode() @@ -42,7 +25,11 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) { const setMode = React.useCallback( (v: boolean) => { 'worklet' - headerMode.set(v ? V1.get() : V0.get()) + headerMode.set(() => + withSpring(v ? 1 : 0, { + overshootClamping: true, + }), + ) }, [headerMode], ) -- cgit 1.4.1