为了账号安全,请及时绑定邮箱和手机立即绑定

React Native:失败的道具类型:道具 businessPhoneNumberChanged

React Native:失败的道具类型:道具 businessPhoneNumberChanged

森林海 2021-06-01 10:57:51
我有一个 React Native 应用程序,成员可以在其中更改他们的公司电话号码,但是一旦用户保存并关闭该屏幕,该电话号码更改就不会持续存在。有一个警告说:失败的道具类型:道具 businessPhoneNumberChanged 在 BusinessDetailsForm 中被标记为必需,但其值未定义。我想知道这是否与BusinessDetailsForm作为功能组件的事实有关,这意味着必须有一个父组件将 props 传递给它,而且我没有在任何地方找到它的父组件:这是功能组件:import React from 'react';import {View, Text, ScrollView, TouchableOpacity} from 'react-native';import Icon from 'react-native-vector-icons/MaterialIcons';import {v2Colors, v2Fonts, v2ButtonStyles} from 'theme';import {Divider, Input, CheckBox} from 'common-components';import {TextButton} from 'react-native-material-buttons';import PropTypes from 'prop-types';import {ScaledSheet} from 'react-native-size-matters';const propTypes = {  businessName: PropTypes.string.isRequired,  businessNameChanged: PropTypes.func.isRequired,  businessPhoneNumber: PropTypes.string,  businessPhoneNumberChanged: PropTypes.func.isRequired,  businessWebsite: PropTypes.string.isRequired,  businessWebsiteChanged: PropTypes.func.isRequired,  changeBussinessAddressNavigation: PropTypes.func.isRequired,  changeMailingAddressNavigation: PropTypes.func.isRequired,  errors: PropTypes.object,  joinDate: PropTypes.string,  renewDate: PropTypes.string,  saveChanges: PropTypes.func.isRequired,  shortBusinessAddress: PropTypes.object.isRequired,  shortMailingAddress: PropTypes.object,  toggleSameAddresses: PropTypes.func,  useSameAddress: PropTypes.bool,};const BusinessDetailsForm = props => (  <View style={styles.container}>    <ScrollView contentContainerStyle={{paddingBottom: 56}}>      <View style={styles.titleContainer}>        <Text style={styles.title}>{'Business Information'}</Text>      </View>      <View style={styles.inputContainer}>        <View style={styles.icon}>我没有看到 this 的父组件businessPhoneNumberChanged。当我使用 props 时,我会将其设为BusinessDetailsForm基于类的组件,但我不确定这是否是问题所在。我总是假设人们知道他们在做什么。道具类型的作用对我来说也不是 100% 清楚,因为我没有使用它太多。所以抛开我自己的理论,为什么businessPhoneNumberChangedundefined的价值?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 185 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信