Ricker81
Ricker81

Reputation: 3

React Native error - Super expression must either be null or a function, not undefined

I am very new to React Native. I've been following along with a YouTube tutorial, when I tried one of their examples I get the following error message in the iPhone emulator:

Super expression must either be null or a function, not undefined

Here are the screen shots of my code.. (It's not much code at all)

index.ios.js screenshot

viewContainer.js screenshot

Any help would be greatly appreciated, thanks in advance!

Upvotes: 0

Views: 1722

Answers (1)

Belmin Bedak
Belmin Bedak

Reputation: 9201

Since your ViewContainer.js needs to access props that are defined in other class (parent class) you can inherit those things by calling the super() method in the constructor of your child class.

class ViewContainer extends Component {
  constructor() {
    super()
    // Rest of the code...
  }
}

Other thing is that you are missing the import of StyleSheet from 'react-native' in ViewContainer so that's why you were getting error:

undefined is not an object (evaluating '_react2.default.StyleSheet.create')

Upvotes: 1

Related Questions