Replies: 2 comments
|
You can use @@ -20,7 +20,7 @@ import {
} from 'react-native-gesture-handler';
interface Props {
- panY: number; // I think it's not number, idk what 💁🏾
+ panY: Animated.SharedValue<number>;
}
export default function BottomSheet({ panY }: Props) {
@@ -31,7 +31,10 @@ export default function BottomSheet({ panY }: Props) {
// 1. context.startY : Property 'startY' does not exist on type '{}'.
// 2. panY.value : Property 'value' does not exist on type 'number'.
- const gestureHandler = useAnimatedGestureHandler<PanGestureHandlerGestureEvent>(
+ const gestureHandler = useAnimatedGestureHandler<
+ PanGestureHandlerGestureEvent,
+ { startY: number }
+ >(
{
onStart(_, context) {
context.startY = panY.value;or @@ -20,20 +20,19 @@ import {
} from 'react-native-gesture-handler';
interface Props {
- panY: number; // I think it's not number, idk what 💁🏾t
+ panY: Animated.SharedValue<number>;
}
export default function BottomSheet({ panY }: Props) {
const { height } = useWindowDimensions();
-
// THESE ARE ERROR I AM GETTING:
// 1. context.startY : Property 'startY' does not exist on type '{}'.
// 2. panY.value : Property 'value' does not exist on type 'number'.
- const gestureHandler = useAnimatedGestureHandler<PanGestureHandlerGestureEvent>(
+ const gestureHandler = useAnimatedGestureHandler(
{
- onStart(_, context) {
+ onStart(_, context: { startY: number }) {
context.startY = panY.value;
},
onActive(event, context) {Some tips:
|
0 replies
|
Just check return type of the function in The type for Pro tip: Using IntelliJ (as I am) or VSCode, you should be able to command (ctrl in wondows, I think) click the function call to go to the definition. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I am really new in React native Animation world. I found one nice tutorial from youtube about React native Reanimated and make a Scrollable Bottom sheet. The Scrollable bottom sheet works perfect. But in the tutorial, it did not introduce Typescript. I want to implement Typescript for this project. I don't know what should I give props for the
useSharedValueanduseAnimatedGestureHandler'sContext. Can anyone please help me to Implement Typescript for this project. Thank you in Advance.I shared my code in Expo-snacks.
Ps: In snacks it will only works in IOS or Android, in WebView it will throw an error.This is the Animation component
This is the parent component where I am importing the Bottom sheet
All reactions