kaizen
kaizen

Reputation: 1638

is there a difference between using <Container> and <View> in NativeBase ui library?

NativeBase says to wrap all components inside <Container></Container> tag.

  1. Does it mean to replace all <View></View> tags?
  2. Are there any differences in functionality or layout when using all <Container> tags to replace all <View> tags and vice versa?
  3. Should I just use one <Container> per screen and use <View> for the rest of the containers inside that screen?

Upvotes: 1

Views: 1551

Answers (1)

Mahdi N
Mahdi N

Reputation: 2178

The 3rd point in your question is the correct one. Container component should be used only one time per screen to wrap all your children components, it's a bit like React.Fragment.

Container takes generally three children components

<Container>
   <Header> //<-always on top
      ...
   </Header>
   <Content> //<-supports scrolling
      ...
   </Content>
   <Footer> //<-always in the bottom
      ...
   </Footer>
</Container>

Are there any differences in functionality or layout when using all tags to replace all tags and vice versa?

It's not recommended to replace all View with Container because Container has its default styles and it will not behave the same as if you use View component to wrap components.

Upvotes: 2

Related Questions