因此,在运行我的应用程序时,我总是收到一个奇怪的错误。我进行了一些研究,但没有一种解决方案适合我的情况。
首先,这里是引发问题的代码:
numeric Series
麻烦的代码是按钮。我不知道为什么会引发此错误:
警告:React.createElement:类型无效-预期为字符串 (对于内置组件)或类/函数(对于复合 组件),但得到了:对象。
import React, { Component } from "react";
import { View, Text, TextInput, ActivityIndicator } from "react-native";
import SvgUri from "react-native-svg-uri";
import tokenStore from "../../stores/token";
import authApi from "../../api/authApi";
import { toast } from "../../helpers";
import Button from "../../components/Button";
import HeaderButton from "../../components/Button";
import ScrollWrapper from "../../components/ScrollWrapper";
import Container from "../../components/Container";
import Input from "../../components/Input";
import ContentGroup from "../../components/Content/Group";
import Label from "../../components/Label";
import Logo from "../../components/Logo";
import * as apps from "../../themes/apps";
import LoginPageStyles from "./LoginPage.styles";
import catalyst_logo_white from "../../styles/images/catalyst_logo_white.svg";
type Props = {};
export default class LoginPage extends Component<Props> {
state = { loading: false, email: "", password: "" };
setLoading(loading: boolean) {
this.state.loading = true;
}
handleSubmit = async () => {
this.setLoading(true);
try {
const token = await authApi.login(this.state.email, this.state.password);
tokenStore.set(token);
} catch (e) {
toast.error("Invalid email or password");
} finally {
this.setLoading(false);
}
};
handleForgotPassword = () => {};
render() {
const style = LoginPageStyles.get();
return (
<ScrollWrapper
contentContainerStyle={{ flexGrow: 1, justifyContent: "center" }}
>
<View style={style.container}>
<View style={style.logoContainer}>
<SvgUri width={186} height={24} source={catalyst_logo_white} />
</View>
<View style={style.loginContainer}>
<Container type="bottom">
<Label>Login</Label>
<Input
size="medium"
icon="user"
placeholder="you@domain.com"
onChangeText={value => this.setState({ email: value })}
value={this.state.email}
autoCapitalize="none"
/>
</Container>
<Container type="bottom">
<Label>Password</Label>
<Input
size="medium"
icon="lock"
placeholder="Your Password"
secureTextEntry={true}
onChangeText={value => this.setState({ password: value })}
value={this.state.password}
autoCapitalize="none"
/>
</Container>
<Container type="bottom" alignment="full">
<Button
size="medium"
style={style.submitButton}
onPress={() => this.props.onSelectApp(apps.contentFuel)}
>
Login
</Button>
</Container>
</View>
</View>
<View style={style.forgotPasswordContainer}>
<Button
linkTo="/forgotPassword"
type="basic"
size="medium"
variant="secondary"
>
Forgot Password
</Button>
</View>
</ScrollWrapper>
);
}
}
我发现的一些解决方案是在Button导入中添加括号,但这没有用。我知道这是导致问题的按钮,因为当我将其完全删除时,该应用程序运行没有问题。
有人知道怎么了吗?