Skip to content

Commit c4ab5a1

Browse files
committed
fix: disable component when reduce motion is enabled
1 parent 02d0f29 commit c4ab5a1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Expandable.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Animated, {
77
useAnimatedReaction,
88
useAnimatedRef,
99
useAnimatedStyle,
10+
useReducedMotion,
1011
useSharedValue,
1112
withDelay,
1213
withTiming,
@@ -27,6 +28,8 @@ const Expandable = ({
2728
easing?: EasingFunction | undefined;
2829
children: JSX.Element | JSX.Element[];
2930
}) => {
31+
const reducedMotion = useReducedMotion();
32+
3033
const [localIsExpanded, setLocalIsExpanded] = React.useState(false);
3134
const [isCollapsing, setIsCollapsing] = React.useState(false);
3235
const delay = renderWhenCollapsed ? 100 : 0;
@@ -119,6 +122,10 @@ const Expandable = ({
119122
[innerComponentHeightSV, localIsExpanded, expanded]
120123
);
121124

125+
if (reducedMotion) {
126+
return expanded ? children : null;
127+
}
128+
122129
return (
123130
<Animated.View
124131
style={[

0 commit comments

Comments
 (0)