- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 RN CLI 开发应用程序。我的 RN 版本是 0.62.2。当我尝试实现 react-native-jitsi-meet
库时,我收到此错误消息 RNCNetinfo.getCurrentState got 3 arguments, expected 2
。在实现这个库之前,Netinfo 工作得非常好。仅当我包含 react-native-jitsi-meet
时才会发生。如果我从我的组件中排除 NetInfo 代码,jitsi meet 开始工作。但是我的应用程序中需要它们。谁能指出我缺少的东西!
注意:我的 minSdkVersion 是 21。
我的依赖项是:
"dependencies": {
"@expo/vector-icons": "^10.2.0",
"@react-native-community/async-storage": "^1.10.3",
"@react-native-community/checkbox": "^0.4.1",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/netinfo": "^5.9.0",
"@react-native-community/picker": "^1.6.1",
"@react-navigation/bottom-tabs": "^5.5.1",
"@react-navigation/drawer": "^5.8.1",
"@react-navigation/native": "^5.5.0",
"@react-navigation/stack": "^5.4.1",
"native-base": "^2.13.12",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-jitsi-meet": "^2.1.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-loading-spinner-overlay": "^1.1.0",
"react-native-reanimated": "^1.9.0",
"react-native-responsive-screen": "^1.4.1",
"react-native-safe-area-context": "^3.0.2",
"react-native-screens": "^2.8.0",
"react-native-snap-carousel": "^3.9.1",
"react-native-sweet-alert": "^2.1.0",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "^10.2.3",
"realm": "^6.0.2"
},
我的组件之一:
// packages
import React, { useContext, useEffect, useState } from 'react';
import { Image, StyleSheet, Text, View } from 'react-native';
import { AuthContext } from './context';
// third party libraries
import { Button, Root } from 'native-base';
import Feather from 'react-native-vector-icons/Feather';
import McIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import NetInfo from "@react-native-community/netinfo";
import SpinnerOverlay from 'react-native-loading-spinner-overlay';
import AsyncStorage from '@react-native-community/async-storage';
import LinearGradient from 'react-native-linear-gradient';
import {
widthPercentageToDP as wp,
heightPercentageToDP as hp,
listenOrientationChange as lor,
removeOrientationListener as rol
} from 'react-native-responsive-screen';
// @TODO: This is to hide a Warning caused by NativeBase after upgrading to RN 0.62
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings([
'Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false`',
]);
// ------- END OF WARNING SUPPRESSION
// assets and components
import defaultImage from './../assets/avatar-default.png';
export const DashboardScreen = ({ navigation }) => {
const [student_details, setStudentDetails] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [site_url, setSiteUrl] = useState('');
const { signOut } = useContext(AuthContext);
useEffect(() => {
lor();
setIsLoading(true);
// checking ineternet connectivity
NetInfo.fetch().then(state => {
if (state.isConnected && state.isInternetReachable) {
let getStudentDetails = async () => {
const userToken = await AsyncStorage.getItem('user_token');
const siteUrl = await AsyncStorage.getItem('site_url');
setSiteUrl(siteUrl);
// sending an api request to get student details
let studentDetailsResponse = await fetch(siteUrl + "/api/student_module/get_student_details", {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + userToken
}
});
// processing the api request
let studentDetailsJson = await studentDetailsResponse.json();
if (studentDetailsJson.status == 'success') {
setIsLoading(false);
setStudentDetails(studentDetailsJson.student_details);
} else if (studentDetailsJson.status == 'token_error') {
setIsLoading(false);
signOut();
} else if (studentDetailsJson.error == 'token_expired') {
setIsLoading(false);
signOut();
} else {
setIsLoading(false);
Toast.show({
text: studentDetailsJson.message,
buttonText: "Okay",
type: "warning",
duration: 30000
});
}
}
getStudentDetails();
} else {
setIsLoading(false);
Toast.show({
text: 'No internet connection!',
buttonText: "Okay",
type: "warning",
duration: 30000
});
}
});
return () => {
rol();
};
}, []);
const onlinePayment = () => {
navigation.navigate('OnlinePayment');
}
const homework = () => {
navigation.navigate('Homework');
}
const syllabus = () => {
navigation.navigate('Syllabus');
}
const onlineClassroom = () => {
navigation.navigate('OnlineClass');
}
const styles = StyleSheet.create({
header: {
paddingTop: hp("3%"),
height: hp("32%"),
borderBottomLeftRadius: 20,
borderBottomRightRadius: 20,
backgroundColor: "#ff3542"
},
dashboardText: {
color: "#FFFFFF",
fontSize: 20,
fontWeight: 'bold',
alignSelf: 'center'
},
dashboardView: {
marginLeft: 'auto',
marginRight: 'auto',
marginTop: -40,
paddingLeft: wp("5%"),
paddingRight: wp("5%"),
width: '85%',
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-around',
flexWrap: 'wrap',
},
menuView: {
display: 'flex',
flexDirection: 'column'
},
dashboardCategory: {
height: 80,
width: 80,
borderRadius: 5,
elevation: 5,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
backgroundColor: '#FFFFFF'
},
iconStyle: {
color: 'grey',
fontSize: 35
},
buttonText: {
marginTop: 10,
paddingBottom: hp("2%"),
color: '#4b2e80',
width: '100%',
textAlign:'center',
fontSize: wp("3.9%")
},
defaultImage: {
marginTop: hp("3%"),
borderRadius: 50,
width: hp("10%"),
height: hp("10%"),
marginRight: hp("2%"),
marginLeft: wp("12%")
},
studnetDetailsWrapper: {
marginTop: hp("1.7%"),
display: 'flex',
flexDirection: 'row',
alignItems: 'center'
},
studentDetailsView: {
marginTop: hp("3%"),
paddingLeft: wp("4%")
}
});
return (
<Root>
<SpinnerOverlay
visible={isLoading}
textContent={'Getting Student Details...'}
textStyle={styles.spinnerTextStyle}
/>
<LinearGradient
start={{x: 0, y: 0}}
end={{x: 1, y: 0}}
colors={['#ff1a29', '#ff3542', '#ff4d58', '#ff8088']}
style={styles.header}>
<Button
transparent
style={{ position: 'absolute', left: wp("5%"), top: hp("1.8%") }}
onPress={() => navigation.openDrawer()}>
<Feather style={{ color: '#FFFFFF' }} name="menu" size={28} />
</Button>
<Text style={styles.dashboardText}>DASHBOARD</Text>
<View style={styles.studnetDetailsWrapper}>
{student_details.profile_image ? <Image source={{ uri: site_url + "/img/StudentPicture/" + student_details.profile_image }} style={styles.defaultImage} /> : <Image source={ defaultImage } style={styles.defaultImage} /> }
<View style={{ marginTop: hp("4%"), borderLeftWidth: 2, width: 2, height: 35, borderColor: "#FFFFFF" }}></View>
<View style={styles.studentDetailsView}>
<Text style={{ color: "#FFFFFF", fontWeight: 'bold', fontSize: hp("2.1%") }}>
{student_details.student_name}
</Text>
<View>
<Text style={{ color: "#FFFFFF", fontWeight: 'bold', fontSize: hp("1.9%"), marginTop: hp("0.2%") }}>
Class: {(typeof student_details.class_info !== 'undefined' && typeof student_details.class_info.ClassName !== 'undefined') ? student_details.class_info.ClassName : '-'} | Roll: {student_details.roll_no}
</Text>
<Text style={{ color: "#FFFFFF", fontWeight: 'bold', fontSize: hp("1.9%"), marginTop: hp("0.2%") }}>
Section: {(typeof student_details.section !== 'undefined' && typeof student_details.section.SectionName !== 'undefined') ? student_details.section.SectionName : '-'} | Group: {(typeof student_details.group !== 'undefined' && typeof student_details.group.GroupName !== 'undefined') ? student_details.group.GroupName : '-'}
</Text>
</View>
</View>
</View>
</LinearGradient>
<View style={styles.dashboardView}>
<View style={styles.menuView}>
<Button light style={styles.dashboardCategory} onPress={homework}>
<Feather style={styles.iconStyle} name="book" size={25} />
</Button>
<Text style={styles.buttonText}> Homework </Text>
</View>
<View>
<Button light style={styles.dashboardCategory} onPress={syllabus}>
<Feather style={styles.iconStyle} name="book-open" size={25} />
</Button>
<Text style={styles.buttonText}> Syllabus </Text>
</View>
<View>
<Button light style={styles.dashboardCategory} onPress={onlinePayment}>
<Feather style={styles.iconStyle} name='dollar-sign' size={25} />
</Button>
<Text style={styles.buttonText}> Pay Online </Text>
</View>
<View>
<Button light style={styles.dashboardCategory} onPress={onlineClassroom}>
<McIcons style={styles.iconStyle} name='google-classroom' size={25} />
</Button>
<Text style={styles.buttonText}> Online Class </Text>
</View>
</View>
</Root>
)
}
最佳答案
解决方案
删除最新版本
npm uninstall @react-native-community/netinfo
npm uninstall @react-native-community/netinfo@5.9.0
安装旧版本
npm uninstall @react-native-community/netinfo@5.0.0
或
yarn add @react-native-community/netinfo@5.0.0
关于react-native - RNCNetinfo.getCurrentState 有 3 个参数,预期为 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62952710/
我对下面的代码 fragment 有疑问。 MainActivity.Java public class MainActivity extends AppCompatActivity implemen
我已经搜索了所有内容,似乎无法找到有关此问题的答案。我的应用程序生活在松散的 XAML 世界中,因此必须依靠 XamlReaders 和树遍历来查找元素。我有一个组件来处理这些 XAML 页面的呈现。
我正在使用 RN CLI 开发应用程序。我的 RN 版本是 0.62.2。当我尝试实现 react-native-jitsi-meet 库时,我收到此错误消息 RNCNetinfo.getCurren
我是一名优秀的程序员,十分优秀!