react-navigation:通过NavigationInjectedProps在屏幕错误之间传递状态

时间:2019-10-02 01:22:15

标签: react-native react-navigation

我正在尝试在state屏幕之间传递stacknavigation。我已经用props设置了MainScreen的NavigationInjectedProps

渲染props时,它显示'id', 'title'的属性undefined

这是我的代码:

import * as React from 'react';
import {NavigationInjectedProps, withNavigation} from 'react-navigation'
import {Card} from 'react-native-elements'

interface Props extends NavigationInjectedProps {
  blog:{
    id:number,
    title:string,
  }
}

class RegisterAgreeScreen extends React.Component<Props, State>{

  render() {

    const { id } = this.props.blog;

    return (
        <View style={{backgroundColor:'red'}}>
          <Card
            id={id}>
          </Card>
        </View>
    );
  }
}

export default withNavigation(RegisterAgreeScreen);

知道我做错了什么吗?

0 个答案:

没有答案