-
-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: assigning to read-only property 'reduceMotion' #1848
fix: assigning to read-only property 'reduceMotion' #1848
Conversation
You can't modify the object inside `worklet`: software-mansion/react-native-reanimated#5430 (comment)
Nice! This warning is really annoying. Could we assign a maintainer for review? Other PRs here don't seem to get much traction 😕 |
Very nice, thanks! I just added this patch and works really well! No more warnings
|
awesome |
when it will be merged? |
still hope and wait it merged |
please merge @gorhom. |
This solved flawlessly, omg I was with this warning for days now, Thanks bro |
What's up with the merger? |
Our app is on fire, please merge this now 😬 🧑🚒 |
I'm still waiting for merge 🥱 |
All of us are waiting 😄 |
We are waiting for @gorhom to merge, please. |
we are waiting for the merge @gorhom |
please merge 🙏 |
For everyone waiting - you can patch the package locally in your projects using |
Waiting for this as well |
Any updates on this PR? |
🙏🏻please merge🙏🏻 |
+1 🙏🏻 |
+1 please merge |
🙏🙏 |
import {
WithSpringConfig,
WithTimingConfig,
withTiming,
withSpring,
AnimationCallback,
ReduceMotion,
} from 'react-native-reanimated';
import { ANIMATION_CONFIGS, ANIMATION_METHOD } from '../constants';
interface AnimateParams {
point: number;
velocity?: number;
configs?: WithSpringConfig | WithTimingConfig;
onComplete?: AnimationCallback;
}
export const animate = ({
point,
configs = undefined,
velocity = 0,
onComplete,
}: AnimateParams) => {
'worklet';
if (!configs) {
configs = ANIMATION_CONFIGS;
}
// Users might have an accessibility setting to reduce motion turned on.
// This prevents the animation from running when presenting the sheet, which results in
// the bottom sheet not even appearing so we need to override it to ensure the animation runs.
let newConfigs = configs;
if (ReduceMotion) {
newConfigs = { ...configs, reduceMotion: ReduceMotion.Never };
}
// detect animation type
const type =
'duration' in newConfigs || 'easing' in newConfigs
? ANIMATION_METHOD.TIMING
: ANIMATION_METHOD.SPRING;
if (type === ANIMATION_METHOD.TIMING) {
return withTiming(point, newConfigs as WithTimingConfig, onComplete);
} else {
return withSpring(
point,
Object.assign({ velocity }, newConfigs) as WithSpringConfig,
onComplete
);
}
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I have just mentioned @gorhom on Twitter, I hope he will notice and check this PR. |
please merge @gorhom. |
I hope he is doing well. I messaged him on Twitter and haven't heard back since then. 😢 |
I've got a reply from @gorhom on Twitter.
|
how to add this patch and where? |
+1 |
u can use bun patch or yarn patch @gorhom/bottom-sheet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @pafry7 for fixing this issue
🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉 |
Is anyone still having this issue? I did the upgrade and it fixed the problem, but I am still seeing it sometimes. I usually happens when I open, close, and then reopen the same bottom sheet. Am I the only one? |
No, you're not. I'm having this issue too. |
Also having this issue |
After upgrading to newest v 5.0.4 it looks fine and no more warnings 🚀 |
Motivation
Upgrading the package to version 4.6.3 results in the following error when rendering BottomSheet in the development.
Cause
Function
animate
insidesrc/utilities/animate.ts
usesworklet
and you cannot modify the objects inside theworklet
, as explained here: software-mansion/react-native-reanimated#5430 (comment).Solution
We have to add
reduceMotion
if:It would be better to do it in one place or we can extract the logic to the utility function
env-info