layout - Bootstrap-like col-row-grid functionality on React Native? -
it better if demonstrate images.
this trying achieve. assume landscape mode tablet size. let's have x amount of elements in array. want map across row until has 3 items in row, goes down. bootstrap, can col-md-4
3 times.
currently using native-base
. has interesting grid systems, not wanted.
this have right now:
<grid> <row> { recipestore.categories.map((category, index) => { return ( <col key={index} style={{height: 300}}> <card> <carditem> <body> <text>{ category.name }</text> </body> </carditem> </card> </col> ) })} </row> </grid>
how can array iteration fill out 3 columns goes next row?
you can use flexwrap: 'wrap'
on parent contain , use flexbasis
on children.
import react, { component } 'react'; import { view, stylesheet } 'react-native'; const abox = () => <view style={styles.box} />; export default class app extends component { render() { return ( <view style={styles.container}> <abox /> <abox /> <abox /> <abox /> <abox /> <abox /> <abox /> <abox /> </view> ); } } const styles = stylesheet.create({ container: { flex: 1, flexwrap: 'wrap', flexdirection: 'row', paddingtop: 20, }, box: { flexbasis: 75, borderwidth: 1, bordercolor: 'black', height: 40, margin: 10, } });
Comments
Post a Comment