[v3] Animated.SharedValue can't be passed to animatedIndex prop in BottomSheetModal
See original GitHub issueBug
Passing an Animated.SharedValue to the animatedIndex prop of BottomSheetModal results in a “No default value” error.
Environment info
Library | Version |
---|---|
@gorhom/bottom-sheet | ^2.0.2 |
expo | ~40.0.0 |
react-native | https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz |
react-native-reanimated | 2.0.0-rc.0 |
react-native-gesture-handler | ~1.8.0 |
Steps To Reproduce
- expo init (basic config)
- yarn add @gorhom/bottom-sheet react-native-reanimated@2.0.0-rc.0 react-native-gesture-handler
- Replace App.js with the code below.
Describe what you expected to happen:
- animatedIndex prop for BottomSheetModal should be able to handle Animated.SharedValue in react-native-reanimated v2
Reproducible sample code
import {
BottomSheetModal,
BottomSheetModalProvider
} from '@gorhom/bottom-sheet';
import React, { useCallback, useRef } from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import { useSharedValue } from "react-native-reanimated";
const App = () => {
const bottomSheetModalRef = useRef(null);
const sharedValue = useSharedValue(0);
const handlePresentModalPress = useCallback(() => {
bottomSheetModalRef.current?.present();
}, []);
return (
<BottomSheetModalProvider>
<View style={styles.container}>
<Button
onPress={handlePresentModalPress}
title="Present Modal"
color="black"
/>
<BottomSheetModal
animatedIndex={sharedValue}
ref={bottomSheetModalRef}
snapPoints={["50%"]}
>
<View style={styles.contentContainer}>
<Text>Hello World!</Text>
</View>
</BottomSheetModal>
</View>
</BottomSheetModalProvider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 24,
justifyContent: 'center',
backgroundColor: 'grey',
},
contentContainer: {
flex: 1,
justifyContent: "center",
alignItems: 'center',
},
});
export default App;
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Props | React Native Bottom Sheet - GitHub Pages
animatedIndex . Animated value to be used as a callback for the index node internally. type, default, required. Animated.
Read more >How to use animatedPosition prop in react-native-bottom-sheet
animatedPosition return shared-values of Reanimated which can be used to animate/interpolate other views in the screen.
Read more >Bottom Sheet in Reanimated 2 - YouTube
Learn how to create a cross-platform animated bottom sheet in React Native.This episode is as short as it can be, using Reanimated 2....
Read more >Making the Bottom Sheet Modal using React Native - Medium
<Modal animated animationType="fade" visible={this. ·... <View style={styles.overlay}> <Animated. · constructor(props) { super(props); this.state ...
Read more >react-spring-bottom-sheet - npm
Every animation and transition use CSS custom properties instead of ... It's worth knowing that the bottom sheet won't render anything but ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah. My apologies — must’ve not copied the right installation instructions. Didn’t mean to waste your time 😅
Thank you for creating and maintaining this library!
@jerryjfwang you are using
@gorhom/bottom-sheet@^2.0.2
that runs on Reanimated v1 , you need to use@gorhom/bottom-sheet@^3