即使console.log输出为真,params.success也变得不确定

时间:2019-06-04 06:25:59

标签: react-native react-navigation

以下数据在React导航3.9中传递给App类:

               params = {
                    myself,
                    result,
                    success: true
                }      

在应用程序中,有几个console.log用于检查值:

console.log("props : ", this.props.navigation.state.params);
console.log("result is : ", this.props.navigation.state.params.result !== null);
console.log("myself is : ", this.props.navigation.state.params.myself !== null);
console.log("success is : ", this.props.navigation.state.params.success);

以下是输出:

06-03 22:30:17.407  8091  8142 I ReactNativeJS: 'props : ', { params:
06-03 22:30:17.407  8091  8142 I ReactNativeJS:    { myself:
06-03 22:30:17.407  8091  8142 I ReactNativeJS:       { id: 22,
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         name: 'jc',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         email: null,
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         cell: 'mycellnumber',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         cell_country_code: '1',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         comp_name: null,
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         status: 'active',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         role: 'admin',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         device_id: '8c9c25711c7d0262',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         user_data: { jwt_secret: '', prev_jwt_secret: '' },
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         last_updated_by_id: null,
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         createdAt: '2019-05-01T19:27:34.461Z',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         updatedAt: '2019-05-23T20:59:45.251Z' },
06-03 22:30:17.407  8091  8142 I ReactNativeJS:      result:
06-03 22:30:17.407  8091  8142 I ReactNativeJS:       { password: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIyLCJkaWQiOiI4YzljMjU3MTFjN2QwMjYyIiwiaWF0IjoxNTU4NjQ1MTgzLCJleHAiOjE1NjAzNzMxODN9.JdxHHKz02LsFOO59KT3GsM8mW-JHnKebgruIxiZQU_g',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         username: '3781567359',
06-03 22:30:17.407  8091  8142 I ReactNativeJS:         service: '' },
06-03 22:30:17.407  8091  8142 I ReactNativeJS:      success: true } }  <<<<<<<====
06-03 22:30:17.414  8091  8142 I ReactNativeJS: 'result is : ', true
06-03 22:30:17.433  8091  8142 I ReactNativeJS: 'myself is : ', true
06-03 22:30:17.434  8091  8142 I ReactNativeJS: 'success is : ', undefined  <<<<<<<===

this.props.navigation.state.params的输出中,success为true。但是this.props.navigation. state.params.success的值为undefined。我不知道为什么success的值从undefined变成true

0 个答案:

没有答案