Почему я получаю супер-выражение Typeerror должно быть нулевым или функцией? - PullRequest
0 голосов
/ 16 февраля 2020

Так что я только начал изучать React Native на прошлой неделе, чтобы попытаться научиться разрабатывать приложения. Я учился на курсе Udemy, и он шел довольно хорошо, пока я не попытался создать новый компонент. Я перечитал урок 3 раза, чтобы попытаться найти свою ошибку, но я не вижу разницы между кодом. Пожалуйста, прости мою любительскую ошибку, где бы она ни была. Файл основного приложения. js содержит следующее:

import React from 'react';
import { StyleSheet, Text, View, Platform, Image, ImageBackground } from 'react-native';
import {Button} from 'native-base';
import Landing from './src/Landing'
import { render } from 'react-dom';

var myBackground = require('./assets/icons/landing.jpg');

export default class App extends React.Component() {
  render() {
  return (
    <View style={styles.container}>
      <Landing />
    </View>
  );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: Platform.OS === "android" ? 50 : 0
  },
});

и код моего компонента:

import React from 'react';
import {View, Text, Image, StyleSheet} from 'react-native';
import {Button} from 'native-base';

var myBackground = require('../assets/icons/landing.jpg');

class Landing extends React.Component {
    render() {
        return(
            <View>
                <ImageBackground style={ styles.imgBackground } source={myBackground}>
                    <View style={styles.viewStyle}>
                    <Text style={styles.titleStyle}>Welcome to PokeSearch</Text>
                    <Button block={true} style={styles.buttonStyle} onPress={()=>{}}>
                        <Text style={styles.buttonText}>Start Searching for Pokemon!</Text>
                    </Button>
                    </View>
                </ImageBackground>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
      flex: 1,
      marginTop: Platform.OS === "android" ? 50 : 0
    },
    imgBackground: {
      width: '100%',
      height: '100%',
      flex: 1 
  },
  viewStyle: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: "center",
    alignItems: "center"
  },
  titleStyle: {
    fontSize: 30,
    color: 'red',
    alignItems: 'center',
  },
  buttonStyle: {
    margin: 10
  },
  buttonText: {
    color: 'red'
  },
  });


export default Landing;

Любая помощь будет принята с благодарностью, я не могу найти где я иду не так ... Вот полная ошибка в эмуляторе: error Заранее спасибо!

1 Ответ

1 голос
/ 16 февраля 2020

изменить export default class App extends React.Component() на export default class App extends React.Component, вам не нужны скобки в компоненте класса.

...