react-native-community/CheckBox 无法解析模块

react-native-community/CheckBox can't resolve module

这看起来是一个容易回答的简单问题,即 npm install @react-native-community/checkbox 但它不起作用。我有一个错误说这个包依赖于 react-native-windows,所以我也下载了这个包,导致我的问题没有解决。

我真的不明白为什么会这样...

这是我的 package.json:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/checkbox": "^0.5.6",
    "expo": "~39.0.2",
    "expo-status-bar": "~1.0.2",
    "moviedb-promise": "^3.1.2",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-image": "^4.0.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.2.tar.gz",
    "react-native-web": "~0.13.12",
    "react-native-windows": "^1.0.0",
    "react-tinder-card": "^1.3.1"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0"
  },
  "private": true
}

编辑

这是我的代码:

import React from 'react'
import { View, Text } from 'react-native';
import CheckBoxSetting from './CheckBoxSetting';
import PressableSetting from './PressableSetting'
import SwitchSetting from './SwitchSetting';

function SettingItemFactory () {
    this.createSettingItem  = function (name, type, initState) {
        let settingItem = <Text/>;
        switch(type){
            case 'pressable':
                settingItem = <PressableSetting title={name}/>;
                break;
            case 'switch':
                settingItem = <SwitchSetting name={name} state={initState}/>
                break;
            case 'check':
                settingItem = <CheckBoxSetting name={name} state={initState}/>
                break;
            default:
                settingItem = <PressableSetting title={name} />;
        }
        return settingItem;
    }
}

export default SettingItemFactory;

import React from 'react'
import {View, Text, ImagePropTypes} from 'react-native'
import CheckBox from '@react-native-community/checkbox'


const CheckBoxSetting = (props) => {
    return (
        <View>
            <Text>
                {props.name}
            </Text>
        </View>
    )
}

export default CheckBoxSetting;

Tushar Khatiwada 在原文的评论中给出了答案post: 截至目前,世博会不支持图书馆。谢谢 Tushar!

如果您在 React Native 项目中使用 expo,expo 提供了一个可以利用的 Checkbox 组件,它似乎使用与 react-native [=] 相同的 API 11=] 组件。 :)

https://docs.expo.io/versions/latest/sdk/checkbox/

博览会不支持。 在 react-native CLI 中,确保链接已完成并执行 pod install。