我正在尝试在React Native中创建自己的组件,并在app类的渲染中调用它,但是显示错误:
typeError:undefined不是函数(评估' instance.render()')
import React, { Component } from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
class MeuComponente extends Component {
return() {
return (
<View>
<Text>Primeiro Parametro</Text>
<Text>Segundo Parametro</Text>
</View>
);
}
}
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<MeuComponente></MeuComponente>
);
}
}
答案 0 :(得分:1)
你写了return()而不是render,试试
import React, { Component } from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
class MeuComponente extends Component {
render() {
return (
<View>
<Text>Primeiro Parametro</Text>
<Text>Segundo Parametro</Text>
</View>
);
}
}
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<MeuComponente></MeuComponente>
);
}
}