简体   繁体   中英

Prevent outer component to add white space at top

In React Native, I have this component:

class List extends Component {
  render() {
    return (
      <Provider store={store}>
        <View style={ styles.container } >
          <ListContainer />
        </View>
      </Provider>
    );
  }
}

The View component has this style:

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignSelf: 'center',
    alignItems: 'center',
    flexDirection: 'row',
    backgroundColor: '#000000',
  }
});

This used to occupy the whole screen. However, I added a StackNavigator component:

const MyApp = StackNavigator({
  List: { screen: List },
  OtherComponent: { screen: OtherComponent }
});

Now my component doesn't occupy the whole screen any more. There is a weird white space at the top. I believe that now my View component is nested within other components and somehow that makes it not occupy the full screen.

So how can I make my View occupy the whole screen again?

It was an issue with StackNavigator . I had to change the code from this:

List: { screen: List },

to this:

List: { screen: List, navigationOptions: { header: null } },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM