gorhom / react-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options ๐Ÿš€
https://gorhom.dev/react-native-bottom-sheet/
MIT License
6.75k stars 744 forks source link

[v4] [Reanimated] Tried to modify key `reduceMotion` of an object which has been already passed to a worklet #1854

Closed Willham12 closed 2 months ago

Willham12 commented 3 months ago

Bug

[Reanimated] Tried to modify key reduceMotion of an object which has been already passed to a worklet. See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#tried-to-modify-key-of-an-object-which-has-been-converted-to-a-shareable

Environment info

Library Version
@gorhom/bottom-sheet 4.6.3
react-native 0.74.1
react-native-reanimated 3.12.0
react-native-gesture-handler 2.16.2

Steps To Reproduce

Open a Bottomsheet

1. 2.

Describe what you expected to happen:

1. 2.

Reproducible sample code

https://github.com/gorhom/react-native-bottom-sheet/blob/4b2a73991d4356ab13904262206abd3e6c8e2869/src/components/bottomSheet/BottomSheet.tsx#L1202

fahad86 commented 3 months ago

https://github.com/gorhom/react-native-bottom-sheet/pull/1848

pixellet14 commented 3 months ago

any solution yet?

MonishReddyDev commented 3 months ago

ANY SOLUTION

paulschreiber commented 3 months ago

@MonishReddyDev @pixellet14 The PR was just approved a few hours ago. Give them time to release a new version.

ebere-hoag commented 2 months ago

Its still showing up for me.

duyrk commented 2 months ago

I have the same problem

ebere-hoag commented 2 months ago

@paulschreiber because its not showing up for you doesn't mean you should put a thumbs down on others comments.

It happens when i open the bottomsheetmodal

paulschreiber commented 2 months ago

@ebere-hoag I am still seeing the problem. I am putting the ๐Ÿ‘Ž because the people are being impatient. The fix has been approved, but not merged or released. Piling on "me too" comments at this point is not helpful.

larsmunkholm commented 2 months ago

@paulschreiber Anyone can approve the pull requests, so I'm not sure that really means anything. It hasn't been approved by @gorhom yet :)

emrekilavuz commented 2 months ago

if I downgrade to 4.6.1, will this warning be gone?

sayan-wholewave commented 2 months ago

if I downgrade to 4.6.1, will this warning be gone?

nothing works till yet.

any update? neither have to use yellowbox/logbox for now.

Nurulloh01 commented 2 months ago

did someone resolve it

shymaaMohmed commented 2 months ago

I have the same problem

mrtawil commented 2 months ago

+1

Willham12 commented 2 months ago

There is a PR https://github.com/gorhom/react-native-bottom-sheet/pull/1848

hdvinhhoang commented 2 months ago

I have the same problem

duyrk commented 2 months ago

1848

Apply the patch that mentioned in this issue, everything will work just fine.

sayan-wholewave commented 2 months ago

There is a PR #1848

thanks. it's working .

kashkashio commented 2 months ago

Merging anytime soon?

H4mxa commented 2 months ago

+1

shuo-hiwintech commented 2 months ago

+1

ksevil commented 2 months ago

+1

LeandroAlberti commented 2 months ago

+1

Zergus-s commented 2 months ago

+1

darkartur commented 2 months ago

+1

thianphat commented 2 months ago

+1

1mike12 commented 2 months ago

another quick workaround without having to fiddle with patches is to set the installation to the proposed PR for now

{
"dependencies": {
    "@gorhom/bottom-sheet": "pafry7/react-native-bottom-sheet#fix/config-reducerMotion-in-worklet",
    }
}
tboy44wiz commented 2 months ago

@1mike12 How do I go about with this your suggestion. Which of the app dependencies?

bgever commented 2 months ago

Thanks for the tip @1mike12, and thanks for the fix @pafry7!

For yarn, add the following to the root package.json (leave your existing dependencies unchanged):

  "resolutions": {
    "@gorhom/bottom-sheet": "github:pafry7/react-native-bottom-sheet#fix/config-reducerMotion-in-worklet"
  },

See https://yarnpkg.com/configuration/manifest#resolutions for what it does.

Then run yarn from the root package:

bart%Barts-MBP2 ~/repos/myapp โžœ yarn                                                                                                                                                                                                                                                                                         
โžค YN0000: ยท Yarn 4.3.1
โžค YN0000: โ”Œ Resolution step
โžค YN0085: โ”‚ + @gorhom/bottom-sheet@https://github.com/pafry7/react-native-bottom-sheet.git#commit=9c4c6eba41197a92990e79591dc9e6546ab9edbb
โžค YN0085: โ”‚ - @gorhom/bottom-sheet@npm:4.6.3
โžค YN0000: โ”” Completed in 33s 710ms
[...]

I had to clear the Metro cache before it started to work.

LukasMod commented 2 months ago

Any idea why even with this fix I get this warning after modal is opened second time?

First open / close is working fine, but next time when I try to open the same or another BottomSheetModal it shows warning with reduceMotion info. Is it something wrong with implementation here? I use same HOC for all my modals. In children it's usually BottomSheetScrollView. Tried both patch-package and this solution. I can see these code changes in my node_modules so fix is there.

const animationConfig: WithSpringConfig | WithTimingConfig = { duration: 400 };

const DrawerModal: React.FC<DrawerModalPropsType> = ({
    visible,
    children,
    onDismiss,
    snapPoints = ['70%'],
    ...rest
}) => {
    const styles = theme();

    const modalRef = useRef<BottomSheetModal>(null);

    if (modalRef) {
        useBottomSheetBack(visible, modalRef, onDismiss);
    }

    useEffect(() => {
        if (visible) {
            InteractionManager.runAfterInteractions(() => {
                modalRef.current?.present();
            });
        } else {
            if (modalRef.current) {
                modalRef.current.close();
            }
        }
    }, [visible]);

    const handleSheetChanges = useCallback((index: number) => {
        if (index === -1) {
            onDismiss?.();
        }
    }, []);

    const renderBackdrop = useCallback(
        (props: BottomSheetBackdropProps) => (
            <BottomSheetBackdrop
                {...props}
                disappearsOnIndex={-1}
                appearsOnIndex={0}
                pressBehavior='close'
            />
        ),
        [],
    );

    return (
        <BottomSheetModal
            ref={modalRef}
            index={0}
            snapPoints={snapPoints}
            onChange={handleSheetChanges}
            animationConfigs={animationConfig}
            enableDismissOnClose
            backdropComponent={renderBackdrop}
            enableContentPanningGesture={false}
            {...rest}>
            {children}
        </BottomSheetModal>
    );
};

export default DrawerModal;
Willham12 commented 2 months ago

fixed with #1848

LukasMod commented 1 month ago

@gorhom Can we reopen this issue or should I create a new one? There is still some problem with reopening bottom sheet, same warnings even with 4.6.4. Not only for me https://github.com/gorhom/react-native-bottom-sheet/pull/1848#issuecomment-2282894602

sumin0gig commented 1 week ago

I have the same issue

bahadiraraz commented 1 week ago

same