LeG*_*aCl 5 node-modules reactjs react-native expo
这看起来像是一个简单的问题和一个简单的答案,
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
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6752 次 |
| 最近记录: |