你好,当我试图实现一个包含注销按钮的头文件时,我得到了这个错误。我得到的错误是检查render method.But can't‘t The error.The文件,在这个文件中我得到的错误如下
import React from "react";
import {
ScrollView,
View,
StyleSheet,
Image,
Text,
Button,
Title,
Header,
AsyncStorage,
Icon
} from "react-native";
import {
RkText,
} from "react-native-ui-kitten";
import Card from "./Card";
import CardSection from "./CardSection";
import Login from './Login';
export class GridV2 extends React.Component {
onPressLogout(){
AsyncStorage.removeItem(token);
}
render() {
return (
<View>
<Header style={{backgroundColor:'#B00000'}}>
<Button
transparent
onPress={() => this.onPressLogout()}
>
<Icon
style= {{color: '#ffffff', fontSize: 25, paddingTop:0}}
name="bars" />
</Button>
</Header>
<Card>
<CardSection>
</CardSection>
</Card>
</View>
);
}
}我要在我的登录screen.Login屏幕中导入此GridV2,如下所示。这段代码中的错误是什么?请帮助..
import React, {Component} from 'react';
import { Container,
Title,
InputGroup,
Input,
Button,
Text,
View,
Spinner,
Item,
Label,
} from 'native-base';
import {
StyleSheet,
Image,
Navigator,
TouchableOpacity,
AsyncStorage,
Linking
} from 'react-native';
import QASection from './QASection';
import GridV2 from './grid2';
class Login extends Component{
state = { userdetail: [] };
constructor(props) {
super(props);
this.initialState = {
isLoading: false,
error: null,
username: '',
password: ''
};
this.state = this.initialState;
}
render() {
return();
}发布于 2018-06-20 17:04:17
您的导出/导入是错误的。请删除所有未使用的导入,并检查您要导入的导入是否在从中导入它们的包中。例如,据我所知,在react-native中没有Header组件(DOC您应该使用命名导入来导入GridV2:
import { GridV2 } from './grid2';或首先导出为默认设置:
export default class GridV2 extends React.Component {请检查您的其他导入文件是否完好无损(文件名等是否正确)。此link很好地解释了导出/导入。
此外,您不应该像这样从render方法返回return ();。相反,返回null,如下所示:
return (null);https://stackoverflow.com/questions/50943999
复制相似问题