第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

cardStyleInterpolator 道具的類型

cardStyleInterpolator 道具的類型

慕運(yùn)維8079593 2023-03-03 10:06:11
我在我的導(dǎo)航堆棧中使用它:  <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 {};  }};但我得到一個(gè)錯(cuò)誤,props它Parameter 'props' implicitly has an 'any' type.可能是什么類型。如果我infer from usage在 VS Code 中,我會(huì)得到這個(gè):(props: { index?: any; current?: any; layouts?: any; })但我不想使用any類型。如果我在控制臺(tái)上打印current和值,我會(huì)得到如下信息:layout當(dāng)前的:{progress: AnimatedInterpolation}progress: AnimatedInterpolation {_listeners: {…}, _children: Array(0), _parent: AnimatedValue, _config: {…}, _interpolation: ?, …}__proto__: Object布局:{screen: {…}}screen: {width: 411.4285583496094, height: 707.4285888671875}__proto__: Object我怎樣才能解決這個(gè)問題?什么是適合在這里使用的類型?
查看完整描述

2 回答

?
拉風(fēng)的咖菲貓

TA貢獻(xiàn)1995條經(jīng)驗(yàn) 獲得超2個(gè)贊

您可以StackCardInterpolationProps從導(dǎo)入類型react-navigation

https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/types.tsx


查看完整回答
反對(duì) 回復(fù) 2023-03-03
?
精慕HU

TA貢獻(xiàn)1845條經(jīng)驗(yàn) 獲得超8個(gè)贊

在 React 導(dǎo)航 6 中

查看in的類型定義StackCardStyleInterpolator@react-navigation。這應(yīng)該適用于 Stack 中的動(dòng)畫屏幕。

forSlideFromLeft您可以像這樣實(shí)現(xiàn)您的方法:

import {

  StackCardInterpolationProps,

  StackCardInterpolatedStyle,

} from "@react-navigation/stack";


const forSlideFromLeft = (

 { current, layouts, index }: StackCardInterpolationProps

): StackCardInterpolatedStyle => {

  const translateX = current.progress.interpolate({

    inputRange: [0, 1],

    outputRange: [-layouts.screen.width, 0],

  });

  if (index === 2) {

    return {

      cardStyle: {

        transform: [{ translateX }],

      },

    };

  } else {

    return {};

  }

};

還有一個(gè)StackHeaderStyleInterpolator用于動(dòng)畫標(biāo)題的。



查看完整回答
反對(duì) 回復(fù) 2023-03-03
  • 2 回答
  • 0 關(guān)注
  • 123 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)