道具类型失败:提供给“ ProductDetail”的“对象”类型的道具“导航”无效,预期的“编号”

时间:2019-06-24 17:50:49

标签: react-native

道具类型失败:提供给navigation的类型object的道具ProductDetail无效,预期number

对于以下代码,我在控制台中收到此警告

家庭课堂

this.props.navigation.push('ProductDetail', { screenBottom: result.safeAreaInsets.bottom });

ProductDetail类

static defaultProps = {
    draggableRange: {
      top: (Platform.OS === 'ios' ? (height / 1.15) : (height - 80)),
      bottom: (Platform.OS === 'ios' ? (height / 3.75) : 146),
    },
    navigation: 0,
}

static propTypes = {
    draggableRange: PropTypes.shape({
      top: PropTypes.number,
      bottom: PropTypes.number,
    }),
    navigation: PropTypes.number,
};

constructor(props) {
    super(props);
    const { navigation } = this.props;
    this.screenBottom = navigation.getParam('screenBottom', 0);
}

警告:道具类型失败:提供给navigation的类型object的道具ProductDetail无效的道具number

1 个答案:

答案 0 :(得分:0)

尝试检查您的propTypes,可能类似于:

  

someComponentName.propTypes = {       导航:PropTypes.number   }