Switch to withSpring to work around Reanimated regression (#4391)

zio/stable
dan 2024-06-06 14:17:26 +01:00 committed by GitHub
parent 1f954c1065
commit 48796449ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 9 deletions

View File

@ -1,10 +1,5 @@
import React from 'react' import React from 'react'
import { import {SharedValue, useSharedValue, withSpring} from 'react-native-reanimated'
Easing,
SharedValue,
useSharedValue,
withTiming,
} from 'react-native-reanimated'
type StateContext = SharedValue<number> type StateContext = SharedValue<number>
type SetContext = (v: boolean) => void type SetContext = (v: boolean) => void
@ -22,9 +17,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
const setMode = React.useCallback( const setMode = React.useCallback(
(v: boolean) => { (v: boolean) => {
'worklet' 'worklet'
mode.value = withTiming(v ? 1 : 0, { mode.value = withSpring(v ? 1 : 0, {
duration: 400, overshootClamping: true,
easing: Easing.bezier(0.25, 0.1, 0.25, 1),
}) })
}, },
[mode], [mode],