“元素类型无效”我仍然一直收到此错误但不知道该怎么做。已尝试<form>
和<Form>
仍然相同。请帮忙:
这是我的AzForm.js保存在:“./ component / testComponent”
import React from 'react'
import { Provider } from 'react-redux'
import { Container, Content, Text, Form } from 'native-base';
//import { createStore } from 'redux' //NOT sure whether I need it, but I still get the same error
import { reduxForm } from 'redux-form'
const SignInForm = props => {
return (
<Form>
</Form>
);
};
export default reduxForm({
form: 'simple' // a unique identifier for this form
})(SignInForm)
这是index.js
的摘录
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Image } from 'react-native';
import { SignInForm } from "./components/AzForm";
export class HomeScreen extends Component {
render() {
return (
<SignInForm />
);
}
}
答案 0 :(得分:0)
更改
export class HomeScreen
到
export default class HomeScreen`
当您在没有default
的情况下导出时,导出的组件将变为所谓的命名导出(每个文件可以包含许多这些导出)。您可以将这些导入为import {HomeScreen} from 'HomeScreen'
React约定是每个文件一个组件。这可以通过使用上面提供的导出默认选项来实现。然后,您可以使用import HomeScreen from 'HomeScreen';