react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

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

Open Willham12 opened this issue 1 year ago โ€ข 4 comments

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

Describe what you expected to happen:

Reproducible sample code

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

Willham12 avatar Jun 04 '24 06:06 Willham12

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

fahad86 avatar Jun 06 '24 02:06 fahad86

any solution yet?

pixellet14 avatar Jun 26 '24 07:06 pixellet14

ANY SOLUTION

MonishReddyDev avatar Jul 02 '24 00:07 MonishReddyDev

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

paulschreiber avatar Jul 02 '24 00:07 paulschreiber

Its still showing up for me.

ebere-hoag avatar Jul 04 '24 14:07 ebere-hoag

I have the same problem

duyrk avatar Jul 05 '24 04:07 duyrk

@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

ebere-hoag avatar Jul 05 '24 17:07 ebere-hoag

@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.

paulschreiber avatar Jul 05 '24 17:07 paulschreiber

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

larsmunkholm avatar Jul 06 '24 12:07 larsmunkholm

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

emrekilavuz avatar Jul 07 '24 15:07 emrekilavuz

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.

sayan-avantai avatar Jul 08 '24 08:07 sayan-avantai

did someone resolve it

Nurulloh01 avatar Jul 08 '24 14:07 Nurulloh01

I have the same problem

shymaaMohmed avatar Jul 09 '24 13:07 shymaaMohmed

+1

mrtawil avatar Jul 09 '24 14:07 mrtawil

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

Willham12 avatar Jul 09 '24 16:07 Willham12

I have the same problem

hdvinhhoang avatar Jul 10 '24 02:07 hdvinhhoang

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

duyrk avatar Jul 10 '24 07:07 duyrk

There is a PR #1848

thanks. it's working .

sayan-avantai avatar Jul 10 '24 08:07 sayan-avantai

Merging anytime soon?

kashkashio avatar Jul 11 '24 18:07 kashkashio

+1

H4mxa avatar Jul 14 '24 05:07 H4mxa

+1

shuo-hiwintech avatar Jul 14 '24 14:07 shuo-hiwintech

+1

ksevil avatar Jul 16 '24 18:07 ksevil

+1

LeandroAlberti avatar Jul 17 '24 14:07 LeandroAlberti

+1

Zergus-s avatar Jul 17 '24 15:07 Zergus-s

+1

darkartur avatar Jul 18 '24 11:07 darkartur

+1

thianphat avatar Jul 19 '24 03:07 thianphat

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",
    }
}

1mike12 avatar Jul 20 '24 01:07 1mike12

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

tboy44wiz avatar Jul 20 '24 06:07 tboy44wiz

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.

bgever avatar Jul 20 '24 07:07 bgever

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;

LukasMod avatar Jul 24 '24 06:07 LukasMod