Skip to content

getInitialState not working in Movies Tutorial #5348

@gugahoi

Description

@gugahoi

Trying to follow the React Native tutorial with the Movies app.
Using iOS or Android everything goes fine until we try to introduce state into the component.
The tutorial does not use ES6 classes but the Hello World App does and this is where it gets confusing.

The tutorial says to add getIntialState which breaks I assume due to using ES6 classes, however using a constructor also does not seem to work so I wanted to know what is the correct way to proceed?

Tutorial

  getInitialState: function() {
    return {
      movies: null,
    };
  },

ES6 Equivalent?

  constructor(props) {
    super(props);
    this.state = {
      movies: null,
    };
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions