javascript - react native blog feed view -


i'm creating react native app , on it's first page(home page) show content of blog feeds , on clicking read more show detailed view of blog feed on next page. so, question how ? here output: output image

so on clicking read more button should open detailed view of blog feed , question how in react native?

here code:

import react, { component } 'react'; import {   activityindicator,   listview,   text,   stylesheet,   view,   touchableopacity } 'react-native'; import {actions, router, scene} 'react-native-router-flux'; import timeago 'react-native-timeago'; import {   card,   carditem,   content,   header,   body,   footer,   footertab,   container,   left,   icon,   right } 'native-base';  import {getimage,contentsnippet} './helpers/helpers'; import htmlview 'react-native-htmlview'; import fitimage 'react-native-fit-image'; export default class home extends component {   constructor(props) {     super(props);     this.state = {       isloading: true     }   }    componentdidmount()       {           return fetch('http://www.cardory.co.uk/jan/json')             .then((response) => response.json())             .then((responsejson) => {               let ds = new listview.datasource({rowhaschanged: (r1, r2) => r1 !==               r2});     this.setstate({       isloading: false,       datasource: ds.clonewithrows(responsejson.items),     }, function() {       // new state     });   })   .catch((error) => {     console.error(error);   });     }      render() {       if (this.state.isloading) {         return (           <view style={{flex: 1, paddingtop: 80}}>             <activityindicator />           </view>         );       }  return (   <container style={{flex: 1, paddingtop: 60}} >   <listview     datasource={this.state.datasource}     renderrow={(rowdata) =>        <card>         <carditem header>           <text style={styles.titleheading}>{rowdata.title}</text>         </carditem>         <carditem cardbody>             <content style={{marginleft:10,marginright:10}}>               <fitimage source={{uri: getimage(rowdata.content_html)}}/>               <htmlview value={contentsnippet(rowdata.content_html.replace(/<img[^>]*>/g,""))}/>             </content>         </carditem>         <carditem>             <left>               <touchableopacity onpress={actions.details}>                 <text>                   read more                 </text>               </touchableopacity>             </left>             <right>               <text>                 <icon name="time"/>                 <timeago time=  {rowdata.date_published}/>               </text>             </right>         </carditem>       </card>     }   />   </container> );     }   }   const styles=stylesheet.create({     textheading:{       fontsize:20,       margintop:20     },     titleheading:{       fontsize:20,       fontweight:'bold',       color:'black',       alignitems:'center',     }   });   module.export=home; 

you should use navigation library, eg. react-navigation.

import { stacknavigator } 'react-navigation'  class home extends component {   // code   // ...     <touchableopacity onpress={() => this.props.navigation.navigate('detail', { rowdata })}>   // ... }  class detail extends component {   // detail view logic   // rowdata available @ this.props.navigation.state.params.rowdata }  const app = stacknavigator({   home: { screen: home },   detail: { screen: detail }, })  export default app 

edit: realized you're using navigation library (react-native-router-flux). think react-navigation easier start with.


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 -