gridview - React Native listview with different type of components -
i developing react native application. on homepage need show posts video, audio, images, blogs, articles etc. confused how achieve . how can make list or grid view different type of components, mix of audio , video, images. backend add image or video or audio or blog , new post created in list.also want add new post beginning , not @ end. appreciated.
you can use flatlist this. it's easy use , performance , recommended react-native (look @ this). simple example of using flatlist can handle list items in separated component or function , pass in renderitem prop of flatlist. can see full document of flatlist in here:
_keyextractor = (item, index) => item.id; _renderitem = ({item}) => ( if (item.type === 'video') { <myvideo item={item}/> } else if (item.type === 'image') { <myimage item={item}/> } else if ... ... ); render() { return ( <flatlist data={datalist} keyextractor={this._keyextractor} renderitem={this._renderitem} /> ); } wiki
Comments
Post a Comment