gpt4 book ai didi

javascript - 元素类型对于react-native-modalbox无效

转载 作者:行者123 更新时间:2023-11-28 03:45:01 25 4
gpt4 key购买 nike

我正在尝试从react-native-modalbox显示模式框。

以下代码显示错误“不变违规:元素类型无效:需要字符串或类/函数,但得到:未定义。您可能忘记从定义它的文件中导出组件。”

// React
import * as React from "react";
import * as RN from "react-native";
import { connect } from "react-redux";

// Managers
import { StyleManager } from "../../../managers/StyleManager";

// Components
import Touchable from "../../components/Touchable";
import Modal from 'react-native-modalbox';
import Button from 'react-native-button';

import { Screen } from "../Screen";

const style = StyleManager.style.SearchScreen;
const ICON_SIZE = 15;

export default connect((state) => state)(class MyScreen extends Screen {

constructor(props) {
super(props);
this.state = {
isOpen: false,
isDisabled: false,
swipeToClose: true,
sliderValue: 0.3
};
}

onClose() {
console.log('Modal just closed');
}

onOpen() {
console.log('Modal just openned');
}

onClosingState(state) {
console.log('the open/close of the swipeToClose just changed');
}

public renderScreen() {
return (

/* Full screen container */
<RN.View style={style.screenContainer}>

{/* Top container */}
<RN.View style={style.topContainer}>
<Button onPress={() => this.refs.modal1.open()} style={style.btn}>Basic modal</Button>
</RN.View>

{/* Bottom container */}
<RN.View style={style.bottomContainer}>

<Modal
style={[style.modal, style.modal1]}
ref={"modal1"}
swipeToClose={this.state.swipeToClose}
onClosed={this.onClose}
onOpened={this.onOpen}
onClosingState={this.onClosingState}>
<RN.Text style={style.text}>Basic modal</RN.Text>
<Button onPress={() => this.setState({ swipeToClose: !this.state.swipeToClose })} style={style.btn}>Disable swipeToClose({this.state.swipeToClose ? "true" : "false"})</Button>
</Modal>

</RN.View>

);
}
});

错误来自模态部分,但我找不到它到底出了什么问题。哪里错了?

在这里您可以看到使用相同的react-native-modalbox组件的工作代码: https://github.com/maxs15/react-native-modalbox/blob/master/Example/index.ios.js

最佳答案

改变

public renderScreen() {

render() {

关于javascript - 元素类型对于react-native-modalbox无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48571636/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com