获取从多屏到单屏的状态



我对 React native 很陌生。我想在一个屏幕上设置信息,包括添加、编辑和显示详细信息,因此我在调用每个事件时设置了状态。

添加时,我设置为添加,编辑时,我设置为编辑,当显示详细信息

时,我设置为显示详细信息并导航它们,就像这样。

屏幕 A:

this.props.navigation.navigate(ROUTE_INVOICE_DETAIL_NAME, { invoice, isEditing: true });

和屏幕 B(详细信息(:

constructor(props) {
    super(props);
    this.isShowDetail = props.navigation.getParam("isShowDetail");
    console.log(this.isShowDetail);
    this.isAdding = props.navigation.getParam("isAdding")
    this.isEditing = props.navigation.getParam("isEditing");
    const { params = {} } = this.props.navigation.state;
    const { invoice = {} } = params;
    const { paid = 0, incurred = 0, transportFee = 0, id} = invoice;
    this.state = {
        id,
        invoice,
        isShowTicketDetail: false,
        customer: {},
        paid,
        incurred,
        transportFee,
        details: {},
    };

我不知道如何获取isEditingisAdding值,它返回未定义。

ROUTE_INVOICE_DETAIL_NAME已声明,我确定它会转到详细信息。

在屏幕 A 上:

this.props.navigation.navigate(ROUTE_INVOICE_DETAIL_NAME, {
                    invoice_data: invoice ,
                    isEditing: true
                })

在屏幕B上,您可以获得如下数据:

let invoice_data = this.props.navigation.state.params.invoice_data
let isEditing = this.props.navigation.state.params.isEditing

相关内容

  • 没有找到相关文章

最新更新