0

Im new in React so i work on a mini project of mine with a simple list. This is the code :

render() {
    if (!this.state.loaded) {
      return this.renderLoadingView();
    }

    return (
        <View>
            <ToolbarAndroid style={styles.toolbar}
               title={"Hello React"}
               titleColor={'#000000'}/>
          <ListView
            dataSource={this.state.dataSource}
            renderRow={this.renderMovie}
            style={styles.listView}/>
      </View>
    );
  }

Also the style code:

 listView: {
    paddingTop: 20,
    backgroundColor: '#F5FCFF',
    flex: 1,
  },

1 Answer 1

3

That's not working because you forgot to set the size of the View. Add flex:1 and it will work properly

styles

listView: {
    paddingTop: 20,
    backgroundColor: '#F5FCFF',
    flex: 1,
},
container: {
    flex: 1
}

render

render() {
    if (!this.state.loaded) {
      return this.renderLoadingView();
    }

    return (
        <View style={styles.container}>
            <ToolbarAndroid style={styles.toolbar}
               title={"Hello React"}
               titleColor={'#000000'}/>
          <ListView
            dataSource={this.state.dataSource}
            renderRow={this.renderMovie}
            style={styles.listView}/>
      </View>
    );
  }

Example with the problem fixed (iOS version)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.