RN dùng Yoga engine của Meta — implement subset Flexbox. Khác biệt quan trọng:
- Default
flexDirectionlàcolumn(web làrow). Cần nhớ:<View>xếp children theo chiều dọc mặc định. flex: 1viết tắt choflexGrow: 1, flexShrink: 1, flexBasis: 0(đa số case web cũng vậy).- Không có
display: block/inline— chỉ flex hoặc absolute.<Text>luôn inline-like trong cùng một<Text>cha, ngoài ra render block. - Không có
gapđến RN 0.71; từ 0.71+ cógap/rowGap/columnGap. - Không có
autocho margin trong vài context cũ —marginLeft: 'auto'để đẩy phải hoạt động trong flex. alignSelf: stretchlà default (web làauto).%đơn vị chỉ work cho width/height/margin/padding/flexBasis — không cho mọi prop.- Không có
float,grid,multi-column,position: sticky.
Một số quirk: aspectRatio được hỗ trợ, transform array thay vì string, position: absolute định vị theo gần nhất parent có position: relative — giống web.
RN uses Meta's Yoga engine, which implements a Flexbox subset. Important differences:
- Default
flexDirectioniscolumn(web isrow). Remember:<View>stacks children vertically by default. flex: 1shorthand maps toflexGrow: 1, flexShrink: 1, flexBasis: 0(most web cases too).- No
display: block/inline— only flex or absolute.<Text>is inline-like within a parent<Text>, otherwise it renders block. - No
gapuntil RN 0.71; 0.71+ supportsgap/rowGap/columnGap. - No
autofor margin in some older contexts —marginLeft: 'auto'to push right works inside flex. alignSelf: stretchis the default (web defaults toauto).%units work only for width/height/margin/padding/flexBasis — not every property.- No
float,grid, multi-column, orposition: sticky.
Quirks: aspectRatio is supported, transform takes an array (not a string), and position: absolute positions against the nearest position: relative parent — same as the web.