-1

I have started working with flex box on React native, on CSS you should set the display to flex but on RN, this is set by default.

What classifies a container object where you can set alignItems, justifyContent?

Does it only need to be a view? or is every single component a potential container?

halfer
  • 19,824
  • 17
  • 99
  • 186
Martin
  • 23,844
  • 55
  • 201
  • 327

2 Answers2

0

In my experience objects that honour flex box are ones you would expect to such as View and ScrollView - whereas views like Text do not and are likened to display: inline-block or <span />.

In the example here, The View within the ScrollView honours it's parents flex properties, and similarly the Text inside the View. However the Text objects do not behave in the same way and if I'm not mistaken, would not appear to change when adjusting it's flex properties.

sooper
  • 5,991
  • 6
  • 40
  • 65
0

Container components are those React Native components which have access to the store. These components make API calls, do processing and contain the business logic of the app. Container components shouldn't have the view logic or presentational logic. The job of container components is to compute the values and pass them as props to the presentational components.

Difference between Presentational Components Container Components

Purpose How things look (markup, styles) How things work (data fetching, state updates)

Aware of Redux No Yes

To read data Read data from props Subscribe to Redux state

To change data Invoke callbacks from props Dispatch Redux actions

Are written By hand Usually generated by React Native Redux

Manav
  • 2,284
  • 1
  • 14
  • 27