我在试着从React Native MaterialAppBar.我在IconButton中使用的图标来自react-native-vector-icon.我不知道为什么我会被错误地说成Element type is invalid: expect a string. Check the render method for IconButton,因为我从React Native Material官方文档中抄袭了准确的代码.

import {AppBar, IconButton} from '@react-native-material/core';
import {Icon} from 'react-native-vector-icons/Entypo';

      <AppBar
        title="Title"
        leading={props => (
          <IconButton
            icon={props => <Icon name="menu" {...props} />}
            {...props}
          />
        )}
      />

推荐答案

==>;试试我的代码,它起作用了.

import {AppBar, IconButton} from '@react-native-material/core';
import Icon from 'react-native-vector-icons/Entypo';

      <AppBar
        title="Title"
        leading={props => (
          <IconButton
            icon={props => <Icon name="menu" {...props} />}
            {...props}
          />
        )}
      />

React-native相关问答推荐

RTK 查询显示互联网何时关闭?

在 react native 平面列表中动态定位弹出窗口

何时在 React Native 中使用辅助功能 Role='link'?

应用程序主体尚未注册

React Native - 当位置在Android上是绝对时视图消失

使用 AsyncStorage 如何以及在何处保存整个 redux 存储

图像背景ResizeMode调整大小模式

react-native 中 android 和 iOS 的图像大小

异步(async)/等待(await)和递归

使用带有 react-native 的 WebView 设置用户代理

使用 resizeMode = contain时的图像对齐

React native Redux - 对象不是构造函数(判断'new ctor(props context)')

在 Android React Native 应用程序中正确使用 Intl

你如何从 React Native 的 EventEmitter 实例中移除一个监听器?

React Native 中的原生广告

使用 Jest 的 react-navigation 测试组件

如何知道 FlatList 中的滚动状态?

如何在本地构建 Expo APK

ReactNative TextInput 不可见 iOS

使用 React-Native 制作多行扩展 TextInput