简体   繁体   English

Expo, React-Native]“失败的道具类型”错误

[英]Expo, React-Native] "Failed prop type" error

I'm making a simple To DO App with react-native and expo xde.我正在使用 react-native 和 expo xde 制作一个简单的 To DO 应用程序。
This is my repo that makes error.(develop branch, commit 636543d125d8de2526c4fb7cd35d67d90638d397)这是我的 repo 出错了。(开发分支,提交 636543d125d8de2526c4fb7cd35d67d90638d397)
https://github.com/daengdaengLee/to-do-manager/tree/636543d125d8de2526c4fb7cd35d67d90638d397 https://github.com/daengdaengLee/to-do-manager/tree/636543d125d8de2526c4fb7cd35d67d90638d397

When I run my project, it makes the error:当我运行我的项目时,它会出错:

Warning: Failed prop type: ActionButton: prop type `eventFunc` is invalid;
it must be a function, usually from the `prop-types` package, but received `undefined`.
    in ActionButton (at App.js:45)
    ...

This is my App.js where makes the error:这是我的 App.js 出错的地方:

...
render() {
  ...
  return (
    <View style={styles.container}>
      <ActionButton // this is line 45. where the error occurs
        icon="❌"
        eventFunc={() => alert('event func')}
      />
    </View>
  );
}
...

This is my ActionButton Component:这是我的 ActionButton 组件:

import React from 'react';
import PropTypes from 'prop-types';

// import Components
import Button from '../../atoms/Button';
import MyView from '../../atoms/MyView';
import MyText from '../../atoms/MyText';

function ActionButton({ icon, eventFunc }) {
  return (
    <Button ownEvent={{ onPressOut: eventFunc }}>
      <MyView styleNames={['iconContainer']}>
        <MyText>
          {icon}
        </MyText>
      </MyView>
    </Button>
  );
}

ActionButton.propTypes = {
  eventFunc: PropTypes.func.isResquired,
  icon: PropTypes.string.isRequired,
};

export default ActionButton;

But something starnge is that the function () => alert('event func') is actually passed.但最重要的是函数() => alert('event func')实际被传递了。
When I press out the Button, it makes the alert message 'event func' actually.当我按下按钮时,它实际上使警报消息“事件功能”。
But the error message said that I'm not passing the function and undefined is passed.但是错误消息说我没有传递函数,而是传递了undefined

What makes this weird situation?是什么造成了这种奇怪的情况?
Please Help me.请帮我。
Thanks for reading.谢谢阅读。 Happy Coding!快乐编码! :) :)

有一个错字ActionButton :改变isResquiredisRequired

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native错误失败的道具类型:提供给`Overlay`的`array`类型的无效道具`children`, - React Native error Failed prop type: Invalid prop `children` of type `array` supplied to `Overlay`, 网络请求在 react-native expo 问题中失败 - Network request failed in react-native expo problem React-Native:本机基础:失败的道具类型:无效的props.style键“ NativeBase”提供给“视图” - React-Native: Native-base: failed prop type: Invalid props.style key “NativeBase” supplied to “View” React Native:失败的道具类型:道具businessPhoneNumberChanged被标记为必需 - React Native: Failed prop type: the prop businessPhoneNumberChanged is marked as required React-native Expo 语音选项 - React-native Expo SpeechOptions react-native 错误:[未处理的 promise 拒绝:错误:获取 Expo 令牌时遇到错误:TypeError:网络请求失败。] - react-native error:[Unhandled promise rejection: Error: Error encountered while fetching Expo token: TypeError: Network request failed.] React Native SearchBar错误:道具类型失败:提供给`ForwardRef(TextInput)`的`array`类型的无效道具`value`,预期`string` - React Native SearchBar Error: Failed prop type: Invalid prop `value` of type `array` supplied to `ForwardRef(TextInput)`, expected `string` 使用 react-native、Firebase 和 expo 的 signinwithemail 链接错误 - signinwithemail link error using react-native, Firebase and expo react-native (expo) 中的“Login.setUser 不是函数”错误 - "Login.setUser is not a function" error in react-native (expo) 在生产模式下运行 expo android 应用程序时出错 - React-native - Error running expo android app in production mode - React-native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM