首页 > 解决方案 > “类型错误:超级表达式必须为空或函数”在本机反应中

问题描述

我正在使用 reactjs。我尝试制作登录布局。这是登录类:

import React, {Components} from 'react';
import {StyleSheet, View, Image} from 'react-native';
import LoginButton from '../components/LoginButton';
export default class Login extends Components {
constructor(props) {
    super(props)
}

render() {
    return (
        <View style={styles.container}>
            <LoginButton
                placeholder={"Login"}
                style={styles.LoginButton}
            />
        </View>
    )
}
..........

这是组件中的 LoginButton:

import React from 'react';
import {StyleSheet, TouchableOpacity, Text} from 'react-native';
export default class LoginButton extends React.Components{
constructor(props) {
  super(props)
}
    render() {
    const {placeholder} =  this.props
    return (
        <TouchableOpacity style={[this.props.style, styles.container]}>
            <Text style={styles.caption}
                placeholder = {placeholder}
            />
        </TouchableOpacity>
    )
}
}`........`

当我运行这段代码时,React Native 给出错误“typeerror: super expression must be null or a function”。我如何解决它 ?

标签: react-native

解决方案


推荐阅读