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.

illustration

currently using native-base. has interesting grid systems, not wanted.

this have right now:

current layout

<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,   } }); 

snack: https://snack.expo.io/hkufup7ub


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -