git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
Add useHeightAnimStyle for animated height/opacity from shared values

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

commitaff56afc34c3d247999cd1a9cac387478420c075 authorMark <mark.eibes@gmail.com> dateSat 21 Feb 2026, 16:39 (7 months ago) parent7e4e398
2 files changed+14
src/Yoga/React/Native/Reanimated.js+7 src/Yoga/React/Native/Reanimated.purs+7
src/Yoga/React/Native/Reanimated.js+7
@@ -46,6 +46,13 @@ export const useInterpolatedStyleImpl = (sv) => (styleMap) => () =>
4646 return style;
4747 });
4848
49+// useAnimatedStyle that directly reads shared values for height and opacity.
50+export const useHeightAnimStyleImpl = (heightSV) => (opacitySV) => () =>
51+ useAnimatedStyle(() => {
52+ "worklet";
53+ return { height: heightSV.value, opacity: opacitySV.value };
54+ });
55+
4956// Read shared value
5057export const readSharedValue = (sv) => () => sv.value;
5158
src/Yoga/React/Native/Reanimated.purs+7
@@ -57,6 +57,7 @@ module Yoga.React.Native.Reanimated
5757 , readValue
5858 , StyleInterp
5959 , useInterpolatedStyle
60+ , useHeightAnimStyle
6061 ) where
6162
6263import Prelude
@@ -121,6 +122,12 @@ foreign import useInterpolatedStyleImpl :: SharedValue Number -> Array StyleInte
121122useInterpolatedStyle :: SharedValue Number -> Array StyleInterp -> Hook UseAnimatedStyle Style
122123useInterpolatedStyle sv styleMap = unsafeHook (useInterpolatedStyleImpl sv styleMap)
123124
125+foreign import useHeightAnimStyleImpl :: SharedValue Number -> SharedValue Number -> Effect Style
126+
127+-- | Animated style that reads height and opacity directly from shared values.
128+useHeightAnimStyle :: SharedValue Number -> SharedValue Number -> Hook UseAnimatedStyle Style
129+useHeightAnimStyle heightSV opacitySV = unsafeHook (useHeightAnimStyleImpl heightSV opacitySV)
130+
124131-- Shared value operations
125132
126133foreign import readSharedValue :: forall a. SharedValue a -> Effect a