【问题标题】:Invariant Violation: View config getter callback for component `div` must be a function (received `undefined`). Make sure to start componen不变违规:组件“div”的视图配置 getter 回调必须是一个函数(收到“未定义”)。确保启动组件
【发布时间】:2022-01-15 06:08:36
【问题描述】:

目前正在尝试构建一个显示棋盘的 react 原生屏幕。我正在使用来自https://github.com/Clariity/react-chessboard 的 react-chessboard 组件。我的代码非常基本,我只想使用 expo 在 IOS 手机上显示屏幕。在 Web 浏览器中运行此应用程序可以正常工作并显示棋盘。但是,如果我想使用移动设备,我会不断收到错误消息:

不变违规:查看组件 div 的配置 getter 回调 必须是一个函数(收到undefined)。确保开始 带有大写字母的组件名称。

为什么会这样?

import { useRef, useState } from 'react';
import {View, Text, StyleSheet} from 'react-native';
import {Chessboard} from 'react-chessboard';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

export default function App() {
  return (
    <view>
      <Chessboard/>
    </view>
  );
}

【问题讨论】:

    标签: javascript reactjs react-native


    【解决方案1】:

    React Native 没有 divs,而是有 Views。 React 库通常不会转换为 React Native 库,因为构建块不同。您很可能必须为您的棋盘找到一个 React Native 库或构建您自己的库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-22
      • 2021-10-05
      • 2021-06-27
      • 2022-12-28
      • 2020-08-14
      • 2020-11-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多