Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

Types for cardStyleInterpolator props

$
0
0

I am using this in my navigation stack:

<NavigationStack.Screen                    name="UserMenu"                    component={UserMenu}                    options={{                      headerShown: false,                      cardStyleInterpolator: forSlideFromLeft,                    }}                  />
const forSlideFromLeft = (props) => {  const { current, layouts } = props;  console.log('PROPS FROM USER MENU', current)  console.log('PROPS FROM USER MENU2', layouts)  const translateX = current.progress.interpolate({    inputRange: [0, 1],    outputRange: [-layouts.screen.width, 0],  });  if (props.index === 2) {    return {      cardStyle: {        transform: [{ translateX }],      },    };  } else {    return {};  }};

but I get an error on props that Parameter 'props' implicitly has an 'any' type. What could be it's type. If I infer from usagein VS Code, I get this:

(props: { index?: any; current?: any; layouts?: any; })

But I don't want to use anytypes. If I print the currentand layout values on the console, I get something like this:

current:

{progress: AnimatedInterpolation}progress: AnimatedInterpolation {_listeners: {…}, _children: Array(0), _parent: AnimatedValue, _config: {…}, _interpolation: ƒ, …}__proto__: Object

layout:

{screen: {…}}screen: {width: 411.4285583496094, height: 707.4285888671875}__proto__: Object

How can I fix this? What would be the suitable type to use here?


Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>