我正在使用RN,并且有几个使用react-native-modalize库的项目,到目前为止没有出现任何问题。但这一次,我创建了一个新项目,并按照教程应用了react-native-modalize,但得到了一个类似于这幅图像的错误。
在这里,我的Login.js:
import React, {useRef} from 'react';
import {
ImageBackground,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import {Modalize} from 'react-native-modalize';
import {login_bottom, login_top} from '../assets';
import {colors} from '../constants';
const Login = ({navigation}) => {
const modalizeRef = useRef(null);
const onPressLogin = () => {
modalizeRef.current?.open();
};
return (
<>
<Modalize ref={modalizeRef}></Modalize>
<View style={styles.container}>
<View style={{flex: 1, justifyContent: 'space-around'}}>
<ImageBackground
source={login_top}
style={{
width: null,
height: '100%',
}}
/>
</View>
<View style={{flex: 1, justifyContent: 'space-around'}}>
<View style={styles.containerLogin}>
<TouchableOpacity style={styles.loginButton} onPress={onPressLogin}>
<Text style={styles.loginButtonText}>LOGIN</Text>
</TouchableOpacity>
</View>
</View>
<View style={{flex: 1, justifyContent: 'space-around'}}>
<ImageBackground
source={login_bottom}
style={{
width: null,
height: '105%',
}}
/>
</View>
</View>
</>
);
};在这里,我的index.js:
/**
* @format
*/
import {AppRegistry} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(App));在这里,我的MainActivity.java:
package com.backbone;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is
* used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "BackBone";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}这就是我的盲从:
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-gesture-handler": "^2.0.0",
"react-native-modalize": "^2.0.12",发布于 2021-12-23 11:01:25
react本机-modalize目前并不是用来支持v2的反应-本机-手势-处理程序.
在Github:https://github.com/jeremybarbet/react-native-modalize/pull/375上有一个公共关系开放
我们得等到这件事解决了。同时,您降低了您的反应本机手势处理程序版本的级别。
https://stackoverflow.com/questions/70254380
复制相似问题