mokam avatar

React Native Flex style

mokam

Published: 18 Jul 2019 › Updated: 18 Jul 2019React Native Flex style

React Native Flex style

이게 꽤 혼동됩니다.

  • 위 4개는 flexDirection: 'column' 일 때.
  • 아래 4개는 flexDirection: 'row' 일 때.

스크린샷 2019-07-18 오후 4.37.49.png

Source Code


  renderFlex() {
    return (
      <ScrollView style={{ width: '100%' }}>
        <View style={{ width: '100%', backgroundColor: '#eaeaef', ...centering }}>
          {this.renderView('flex-start', 'flex-start', 'column')}
          {this.renderView('flex-start', 'flex-end', 'column')}
          {this.renderView('flex-end', 'flex-start', 'column')}
          {this.renderView('flex-end', 'flex-end', 'column')}
        </View>


        <View style={{ width: '100%', backgroundColor: '#eaeaef', ...centering }}>
          {this.renderView('flex-start', 'flex-start', 'row')}
          {this.renderView('flex-start', 'flex-end', 'row')}
          {this.renderView('flex-end', 'flex-start', 'row')}
          {this.renderView('flex-end', 'flex-end', 'row')}
        </View>
      </ScrollView>
    );
  }

  renderView(justify, align, dir) {
    return (
      <View>
        <MText style={esty.tx}>{`[ ${dir} ] : justifyContent: ${justify}, alignItems: ${align}`}</MText>
        <View style={{
          flexDirection: dir, width: 100, height: 60, justifyContent: justify,
          borderWidth: 1, borderColor: '#aaf',
          alignItems: align }}
        >
          <View style={{ width: 30, height: 30, backgroundColor: '#aaa' }} />
          {/* <View style={{ width: 30 height: backgroundColor: aae />
        <View style={{ width: 30 height: backgroundColor: aea /> */}
        </View>
      </View>
    );
  }

Leave React Native Flex style to:

Written by

Read more #react-native posts


Best Posts From mokam

We have not curated any of mokam's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From mokam