<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[React Native Mastery - Medium]]></title>
        <description><![CDATA[Share thought on React Native - Medium]]></description>
        <link>https://medium.com/react-native-mastery?source=rss----e7ad1fe38ced---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>React Native Mastery - Medium</title>
            <link>https://medium.com/react-native-mastery?source=rss----e7ad1fe38ced---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:45:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/react-native-mastery" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #12 : Categories List]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-12-categories-list-a3bcbd027c39?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/a3bcbd027c39</guid>
            <category><![CDATA[react-native-flatlist-key]]></category>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Thu, 20 Feb 2020 17:16:02 GMT</pubDate>
            <atom:updated>2020-02-20T17:16:02.329Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build React Native WordPress App [Expo way] #12 : Categories List</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JrZn_yqcplXggaQz.png" /></figure><p>we will continue on the previous chapter that we finish on fetching categories data from Wordpress API this chapter we will create a screen for display post by categories is simple to screen again we will use code from Home screen for initializing</p><h4>Create a new screen</h4><p>Create a new screen name CategoriesList.js in screens folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/0*BMa_q9Lmhlu77T7B.png" /></figure><p>then, we just import all necessary component</p><pre>import React from &#39;react&#39;;<br>import { View, FlatList, TouchableOpacity } from &#39;react-native&#39;;<br>import { Card, Title, Paragraph } from &#39;react-native-paper&#39;;<br>import moment from &#39;moment&#39;;<br>import HTML from &#39;react-native-htmlview&#39;;<br>export default class CategorieList extends React.Component {<br>    constructor(props) {<br>        super(props);<br><br>        this.state = {<br>            post: [],<br>        };<br>    }<br>}</pre><p>post-state use for keep post data , moment for display datetime and react-native html-view for render HTML</p><p>then we register new screen on Navigator.js by create stack navigation for Categories</p><pre>function CategorieStack() {<br>    return (<br>        &lt;Stack.Navigator&gt;<br>            &lt;Stack.Screen name=&quot;Categories&quot; component={Categories} /&gt;<br>            &lt;Stack.Screen name=&quot;CategorieList&quot; component={CategorieList} /&gt;<br>        &lt;/Stack.Navigator&gt;<br>    );<br>}</pre><p>then change screen component in Tab navigation</p><pre>&lt;Tab.Screen name=&quot;Categorie&quot; component={CategorieStack} /&gt;</pre><h4>Fetching Post</h4><p>next, we want to fetch post by categories id that pass from Categories Screen</p><pre>componentDidMount() {<br>   this.fetchPost();<br> }<br><br> async fetchPost() {<br>   let categorie_id = this.props.route.params?.categorie_id<br>   const response = await fetch(<br>     `https://kriss.io/wp-json/wp/v2/posts?categories=${categorie_id}`,<br>   );<br>   const posts = await response.json();<br>   this.setState({posts});<br> }</pre><p>in react-navigation version 5 GetParam function will be deprecated and new params will add we use new method get parameter then pass to fetch function then we use componentDidMount call function</p><p>next, we create post item again but now your will see repetition code the FlatList item use for display post item will use for every screen now we can separate to component</p><pre>import React, { Component } from &#39;react&#39;<br>import { ActivityIndicator, View, FlatList, TouchableOpacity } from &#39;react-native&#39;<br>import {<br>    Avatar,<br>    Card,<br>    Title,<br>    Paragraph,<br>    List,<br>    Headline,<br>} from &#39;react-native-paper&#39;;<br>import HTMLRender from &#39;react-native-htmlview&#39;<br>import ImageLoad from &#39;react-native-image-placeholder&#39;;<br>import moment from &#39;moment&#39;<br>export default ({ item, navigation }) =&gt; {<br><br>    return (<br>        &lt;View&gt;<br>            &lt;TouchableOpacity<br>                onPress={() =&gt;<br>                    navigation.navigate(&#39;SinglePost&#39;, {<br>                        post_id: item.id,<br>                    })<br>                }&gt;<br>                &lt;Card<br>                    style={{<br>                        shadowOffset: { width: 5, height: 5 },<br>                        width: &#39;90%&#39;,<br>                        borderRadius: 12,<br>                        alignSelf: &#39;center&#39;,<br>                        marginBottom: 10,<br>                    }}&gt;<br>                    &lt;Card.Content&gt;<br>                        &lt;Title&gt;{item.title.rendered}&lt;/Title&gt;<br>                        &lt;Paragraph&gt;Published on {moment(item.date).fromNow()}&lt;/Paragraph&gt;<br>                    &lt;/Card.Content&gt;<br>                    &lt;ImageLoad<br>                        style={{ width: &#39;100%&#39;, height: 300 }}<br>                        loadingStyle={{ size: &#39;large&#39;, color: &#39;blue&#39; }}<br>                        source={{ uri: item.jetpack_featured_media_url }}<br>                    /&gt;<br>                    &lt;Card.Content&gt;<br><br>                        &lt;HTMLRender value={item.excerpt.rendered} /&gt;<br><br>                    &lt;/Card.Content&gt;<br>                &lt;/Card&gt;<br>            &lt;/TouchableOpacity&gt;<br>        &lt;/View&gt;<br>    )<br><br>}</pre><p>we create a functional component that receives item and navigation object from a parent component for parent component we import component like that</p><p>first import component</p><pre>import ContentCard from &#39;../components/ContentCard.js&#39;</pre><p>then using in FlatList like that</p><pre>renderItem={({ item }) =&gt; (<br>   &lt;ContentCard item={item} navigation={this.props.navigation} /&gt;<br>)}</pre><p>your will see Home screen work fine again</p><p>for CategorieList screen we import ContentCard component again</p><pre>let categorie_name = this.props.route.params?.categorie_name<br>       return (<br>           &lt;View&gt;<br>               &lt;Title style={{ marginLeft: 30 }} &gt;{categorie_name}&lt;/Title&gt;<br>               &lt;FlatList<br>                   data={this.state.posts}<br>                   renderItem={({ item }) =&gt; (<br>                       &lt;ContentCard item={item} navigation={this.props.navigation} /&gt;<br>                   )}<br>                   keyExtractor={(item, index) =&gt; index.toString()}<br>               /&gt;<br>           &lt;/View&gt;<br>       );</pre><p>now we saw a post by categories</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/0*oX4QsglhX0TFVv0I.jpg" /></figure><h4>Conclusion</h4><p>In this chapter we learn how to fetching post by categories . also separate FlatList item to component for the next chapter we will set up Firebase ,Formik,Yup for store message on realtime databse</p><h4>Author note</h4><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-12-categories-list/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3bcbd027c39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-12-categories-list-a3bcbd027c39">Build React Native WordPress App [Expo way] #12 : Categories List</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #16 :: manually and automatic change theme]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-16-manually-and-automatic-change-theme-33f7661d620a?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/33f7661d620a</guid>
            <category><![CDATA[react-native-dark-theme]]></category>
            <category><![CDATA[react-native-context-api]]></category>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Thu, 20 Feb 2020 17:11:05 GMT</pubDate>
            <atom:updated>2020-02-20T17:12:19.641Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a3UeTmcWeexAPpwr.png" /></figure><p>in this chapter, we will continue from the previous chapter that we successfully set up dark mode but not at all compatible react native htmlview not auto change dark mode that required do manually this chapter we separate post item to individual component and add custom style from react-native paper for switch dark and light theme</p><h4>Create ThemeManager Context</h4><p>first we create Context component that using for toggling theme or get the theme variable create ThemeController.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/0*H-otKXMehVaodo9V.png" /></figure><p>next, add code below to file</p><pre>import React, { createContext, useState } from &quot;react&quot;;<br><br>export const ThemeContext = createContext();<br>export const ThemeController = ({ children }) =&gt; {<br>  const [theme, setTheme] = useState(false);<br><br>  const toggleTheme = value =&gt; {<br>    if (value === true) {<br>      setTheme(true);<br>    } else {<br>      setTheme(false);<br>    }<br>  };<br>  return (<br>    &lt;ThemeContext.Provider value={{ theme, toggleTheme }}&gt;<br>      {children}<br>    &lt;/ThemeContext.Provider&gt;<br>  );<br>};</pre><p>first, we create a new context object then create function ThemeController and create theme state variable then create simple function for toggle theme variable last thing we return theme state and toggle function</p><h4>inject to Navigator</h4><p>now we inject theme context while wrap Navigator Component in App.js</p><pre>import { ThemeController } from &quot;./src/components/ThemeController&quot;;<br>export default function App() {<br>  return (<br>    &lt;ThemeController&gt;<br>      &lt;Navigators /&gt;<br>    &lt;/ThemeController&gt;<br>  );<br>}</pre><p>then we using theme context control theme in Navigator.js</p><pre>import React, { useContext } from &#39;react&#39;<br>import { ThemeContext } from &quot;../components/ThemeController&quot;;</pre><p>we need to import ThemeContext and useContext for getting data from ThemeController</p><p>then inject theme variable for control theme state</p><pre>export default function Navigator() {<br>    const { theme } = useContext(ThemeContext);<br>    let paper_theme = theme ? PaperDarkTheme : PaperDefaultTheme;<br>    let nav_theme = theme ? DarkTheme : DefaultTheme;<br><br>    return (<br>        &lt;PaperProvider theme={paper_theme}&gt;<br>            &lt;NavigationContainer theme={nav_theme}&gt;<br>........<br>            &lt;/NavigationContainer&gt;<br>        &lt;/PaperProvider&gt;<br>    );<br>}</pre><p>now we have done on setup theme</p><h4>Toggle with Switch</h4><p>we use switch for toggle theme in Setting.js</p><pre>import React, { Component,useContext } from &#39;react&#39;<br>import { Text, View, TouchableOpacity } from &#39;react-native&#39;<br>import { List, Switch } from &quot;react-native-paper&quot;;<br>import { ThemeContext } from &quot;../components/ThemeController&quot;;</pre><p>we import Context and useContext again for using react hook we need to convert the class to function component</p><pre>import React, { Component, useContext } from &#39;react&#39;<br>import { Text, View, TouchableOpacity } from &#39;react-native&#39;<br>import { List, Switch } from &quot;react-native-paper&quot;;<br>import { ThemeContext } from &quot;../components/ThemeController&quot;;<br>const Setting = () =&gt; {<br>    const { toggleTheme, theme } = useContext(ThemeContext);<br>    return (<br>        &lt;View&gt;<br>            &lt;List.Item<br>                title=&quot;Dark Mode&quot;<br>                left={() =&gt; &lt;List.Icon icon=&quot;brightness-4&quot; /&gt;}<br>                right={() =&gt; &lt;Switch value={theme} onValueChange={toggleTheme} /&gt;}<br>            /&gt;</pre><p>we get toggleTheme function and theme state from ThemeContext then using in Switch component</p><p>finally, we see the result here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*9eA5yV-frgLqsw_2.gif" /></figure><h4>Conclusion</h4><p>we success to use React Context for control Theme by manually next chapter we will learn how to change automatically based on operating system preference</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-16-making-card-component/"><em>Kriss</em></a><em>.</em></p><h3>Author note</h3><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33f7661d620a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-16-manually-and-automatic-change-theme-33f7661d620a">Build React Native WordPress App [Expo way] #16 :: manually and automatic change theme</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #15 : setup dark mode]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-15-setup-dark-mode-c0617a58314a?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/c0617a58314a</guid>
            <category><![CDATA[react-native-themes-free]]></category>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Thu, 20 Feb 2020 15:21:24 GMT</pubDate>
            <atom:updated>2020-02-20T15:21:24.232Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build React Native WordPress App [Expo way] #15 : setup dark mode</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VRYzQnud5r9lOTe3.png" /></figure><p>in this chapter, we will set up dark mode for react-navigation and react-native paper, fortunately, two packages have already builtin dark mode feature but we need to</p><h4>Active dark mode in React navigation</h4><p>first, we need to import theme configuration from react-navigation and react-native paper</p><p>in Navigator.js</p><pre>import {<br>    NavigationContainer,<br>    DefaultTheme,<br>    DarkTheme<br>} from &quot;@react-navigation/native&quot;;</pre><p>and also import theme configuration from react-native paper</p><pre>import {<br>    Provider as PaperProvider,<br>    DefaultTheme as PaperDefaultTheme,<br>    DarkTheme as PaperDarkTheme<br>} from &quot;react-native-paper&quot;;</pre><p>next step we activate two themes on main component</p><pre>&lt;PaperProvider theme={PaperDarkTheme} &gt;<br>          &lt;NavigationContainer theme={DarkTheme} &gt;<br>             ....................<br>          &lt;/NavigationContainer&gt;<br>      &lt;/PaperProvider&gt;</pre><p>we use Paper theme provider wrap react-navigation then set two-component to dark theme</p><p>now when your see app will go dark</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/0*bJUFfL7grTzQNnpV.jpg" /></figure><h4>inject theme variable to another component</h4><p>but your will see exert will not change following other components so that we need to manual configuration first in ContentCard component we import HOC name withTheme from <a href="https://callstack.github.io/react-native-paper/">react-native-paper</a></p><pre>import {<br>    Avatar,<br>    Card,<br>    Title,<br>    Paragraph,<br>    List,<br>    withTheme,<br>} from &#39;react-native-paper&#39;;</pre><p>then we update function by use withTheme wrap function before export</p><pre>export default withTheme(ContentCard)</pre><p>next, we can pass theme configuration props to function</p><pre>const ContentCard = ({ item, navigation, theme }) =&gt; {}</pre><p>now we can use theme colors in react-native-htmlview package</p><pre>&lt;HTMLRender value={item.excerpt.rendered}<br> stylesheet={{<br>     p: {<br>         fontWeight: &#39;300&#39;,<br>         color: theme.colors.text, <br>     }<br> }} /&gt;</pre><p>now text color will change follow the theme</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/0*HAzBMkrkJCYKzFEK.jpg" /></figure><p>next, we can do again in SinglePost screen but in htmlview component we need more configuration</p><pre>&lt;HTML value={post[0].content.rendered} addLineBreaks={false}<br>   stylesheet={{<br>       p: {<br>           color: colors.text, // make links coloured pink<br>       },<br>       pre: {<br>           color: colors.primary, // make links coloured pink<br>       }<br>   }} /&gt;</pre><p>here result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/0*0LfXekcDal6m9kTa.jpg" /></figure><h4>conclusion</h4><p>this chapter we setup theme for our app that pretty easy because two main packages in our app is already builtin theme configuration next chapter we will learn how to toggle theme using React Context</p><h4>Author note</h4><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-15-setup-dark-mode/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0617a58314a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-15-setup-dark-mode-c0617a58314a">Build React Native WordPress App [Expo way] #15 : setup dark mode</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #11 : Categories Screen]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-11-categories-screen-eaf7b8b890b?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/eaf7b8b890b</guid>
            <category><![CDATA[react-native-fetch-blob]]></category>
            <category><![CDATA[react-native-fetch-async]]></category>
            <category><![CDATA[react-native-fetch-cors]]></category>
            <category><![CDATA[react-native-fetch]]></category>
            <category><![CDATA[react-native-fetch-cache]]></category>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Mon, 17 Feb 2020 05:14:13 GMT</pubDate>
            <atom:updated>2020-02-17T05:14:13.112Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build React Native WordPress App [Expo way] #11 : Categories Screen</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-Mb3URki7656_E9P.png" /></figure><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p>Here, we are going to implement the Categories screen. This screen will contain the list of categories related to the article posts. And on clicking on these categories, we will navigate to the posts which are based on that respective category.</p><p>The implementation is simple. We are going to fetch the categories data and display it with the FlatList component. And by using the TouchableOpacity component, we will navigate to the new list screen which will display the list of article posts based on that category.</p><p>First, we need to open the Categories.js file and import necessary components and define some required state as well as shown in the code snippet below:</p><pre>import React from &#39;react&#39;;<br>import {<br>  FlatList,<br>  ScrollView,<br>  View,<br>  TouchableOpacity,<br>} from &#39;react-native&#39;; <br>import { Card, Title } from &#39;react-native-paper&#39;<br>export default class Categories extends React.Component {<br>  constructor(props) {<br>    super(props);<br><br>    this.state = {<br>      loading: false,<br>      categories: [],<br>    };<br>  }</pre><p>Here, we have defined the loading state to display the loader on fetching of data and categories to store the categories list data. Now, we need to create a function called fetchCategorie() which will fetch all the categories data from the WordPress API as shown in the code snippet below:</p><pre>componentDidMount() {<br>    this.fetchCategorie();<br>  }<br>  async fetchCategorie() {<br>    this.setState({ loading: true });<br>    const response = await fetch(`https://kriss.io/wp-json/wp/v2/categories`);<br>    const categories = await response.json();<br><br>    this.setState({<br>      categories: categories<br>    });<br>  }</pre><p>Here, we have fetched the categories data using the fetch function. Then, we parse it to JSON and store it in the categories state. Then, we have called the function in the componentDidMount hook.</p><p>Now, we need to add the data to FlatList in the render() function of Categories screen as shown in the code snippet below:</p><pre>render() {<br>    return (<br>      &lt;ScrollView&gt;<br>        &lt;FlatList<br>          data={this.state.categories}<br>          renderItem={({item}) =&gt; (<br>            &lt;TouchableOpacity<br>              onPress={() =&gt;<br>                this.props.navigation.navigate(&#39;CategorieList&#39;, {<br>                  categorie_id: item.id,<br>                  categorie_name: item.name<br>                })<br>              }&gt;<br>              &lt;Card&gt;<br>                &lt;Card.Content&gt;<br>                  &lt;Title&gt;{item.name}&lt;/Title&gt;<br>                &lt;/Card.Content&gt;<br>              &lt;/Card&gt;<br>            &lt;/TouchableOpacity&gt;<br>          )}<br>          keyExtractor={(item, index) =&gt; index}<br>        /&gt;<br>      &lt;/ScrollView&gt;<br>    );<br>  }<br>}</pre><p>Here, we have the template in the FlatList component. The FlatList is configured with data from for categories data and keyExtractor prop for the key data. Then, the renderItem prop returns the template for the categories list. The template has the TouchableOpacity as the parent component which has navigation configured to the CategorieList screen. We are going to implement the CategorieList screen later. Then, we have used the Card component and its subcomponents to display the category name.</p><p>Hence, we will get the following result in the emulator screens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/0*JIIyFMDHQb8qeSRo.png" /></figure><h4>Conclusion</h4><p>As we can see, we have got the categories list in the Categories list. By tapping on any list item, we need to navigate to the CategorieList screen which will display the articles related to that category. in next chapter we will implement Screen for display post from individual categories</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-11-categories-screen/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaf7b8b890b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-11-categories-screen-eaf7b8b890b">Build React Native WordPress App [Expo way] #11 : Categories Screen</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #10 : Remove and Render bookmark]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-10-remove-and-render-bookmark-49165a49e778?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/49165a49e778</guid>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Mon, 17 Feb 2020 04:52:21 GMT</pubDate>
            <atom:updated>2020-02-17T04:52:21.515Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7cmBHVSF8WtDxnGW.png" /></figure><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p>Here, we are going to implement the removing of the bookmark from the articles. This case is simpler than saving the bookmarks. Here, we are going to define a function called removeBookMark. For that, we need to use the code from the following code snippet:</p><pre>removeBookMark = async post_id =&gt; {<br>       this.setState({ bookmark: false });<br>       const bookmark = await AsyncStorage.getItem(&#39;bookmark&#39;).then(token =&gt; {<br>           const res = JSON.parse(token);<br>           return res.filter(e =&gt; e !== post_id);<br>       });<br>       await AsyncStorage.setItem(&#39;bookmark&#39;, JSON.stringify(bookmark));<br>   };</pre><p>Here, we have changed the state of already_bookmark to false. Then, we have got the book item using the getItem function of the AsyncStorage module. Then, we parse the response to JSON and store it in res constant. Then using the filter HOC we remove the post id from the bookmark. Then, we save the remaining value in the bookmark array using setItem again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*GRNYHYBHLSZf3ktu.png" /></figure><h4>Render Bookmark</h4><p>Here, we are going to change the value of the bookmark state based on if the article is bookmarked or not. This bookmark state will handle the showing of bookmarked or not bookmarked template in the SinglePost screen. For that, we need to create a new function called renderBookMark as shown in the code snippet below:</p><pre>renderBookMark = async post_id =&gt; {<br>       await AsyncStorage.getItem(&#39;bookmark&#39;).then(token =&gt; {<br>           const res = JSON.parse(token);<br>           let data = res.find(value =&gt; value === post_id);<br>           if (data !== null) {<br>                let data = res.find(value =&gt; value === post_id);<br>                return data == null<br>                    ? this.setState({ bookmark: false })<br>                    : this.setState({ bookmark: true });<br>            }<br>       });<br>   };</pre><p>Here, the function takes post id as a parameter. Then, by using the post id, we get the bookmark ids using the getItem function of AsyncStorage. After we get the values, we parse it and then check if the articles post id is present in the bookmark array or not. If present, we set the bookmark state to true else we set it to false.</p><p>Then, we need to call this function on componentDidMount() and set post id as a parameter which we get from the navigation props as shown in the code snippet below:</p><pre>componentDidMount() {<br>    this.fetchPost().then(()=&gt;{<br>       this.renderBookMark(this.props.navigation.getParam(&#39;post_id&#39;));<br>    });<br>   <br>  }</pre><p>Hence, we will get the following result in the emulator screens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*27HXpl038MkeEFpI.png" /></figure><p>As we can see, we have successfully implemented the bookmark feature in the SinglePost screen. Now, we are able to bookmark the articles. But, we need to show the bookmarked post somewhere as well. We are going to do that in the Bookmark screen in the Bookmark.js file.</p><h4>Summary</h4><p>In this chapter, we learned how to remove and render the bookmark. Then, making use of the AsyncStorage and fetch method, Next chapter, we will continue fetched the bookmarked post to be displayed on the Bookmark screen. how to re-fetch the bookmarked post every time we enter the Bookmark screen so that new bookmarks show up.</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-10-remove-and-render-bookmark/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49165a49e778" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-10-remove-and-render-bookmark-49165a49e778">Build React Native WordPress App [Expo way] #10 : Remove and Render bookmark</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #9 : Saving bookmark]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-9-saving-bookmark-712bc2592781?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/712bc2592781</guid>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Mon, 17 Feb 2020 04:10:25 GMT</pubDate>
            <atom:updated>2020-02-17T04:10:25.219Z</atom:updated>
            <content:encoded><![CDATA[<p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p>Here, we are going to learn how to bookmark the articles so that we can easily access them in our Bookmark screen later. The process is simple. We are going to save post id to Asyncstorage from the SinglePost screen and then fetch the articles on the bookmark screen. Here, we are going to add the bookmark icon to the SinglePost screen and configure its functionality.</p><p>But first, we need to define the state variable called bookmark in the SinglePost.js file in order to handle the showing of bookmark enabled or disabled icon. For that, we need to use the code from the following code snippet:</p><pre>constructor(props) {<br>    super(props);<br>    this.state = {<br>      isloading: true,<br>      post: [],<br>      bookmark: false,<br>    };<br>  }</pre><p>Then, we need to add the Bookmark icon to the screen. For that, we need to use the code from the following code snippet:</p><pre>&lt;List.Item<br>  title={`Published on ${moment(<br>    post[0].date,<br>    &#39;YYYYMMDD&#39;,<br>  ).fromNow()}`}<br>  right={props =&gt; {<br>    if (this.state.already_bookmark ) {<br>      return (<br>        &lt;TouchableOpacity<br>          onPress={() =&gt; this.removeBookMark(post[0].id)}&gt;<br>          &lt;MaterialCommunityIcons name=&quot;bookmark&quot; size={30} /&gt;<br>        &lt;/TouchableOpacity&gt;<br>      );<br>    } else {<br>      return (<br>        &lt;TouchableOpacity<br>          onPress={() =&gt; this.saveBookMark(post[0].id)}&gt;<br>          &lt;MaterialCommunityIcons name=&quot;bookmark-outline&quot; size={30} /&gt;<br>        &lt;/TouchableOpacity&gt;<br>      );<br>    }<br>  }}<br>/&gt;</pre><p>we have displayed the bookmark icon template based on the bookmark state. The template has the TouchableOpacity component that wraps the MaterialCommunityIcons component. In the onPress events we have called the removeBookMark and saveBookMark function. These functions are use to bookmark the article or remove the bookmark from the article.</p><p>Hence, we will get the following result in the emulator screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/0*yXq8mhULyI3tsPUb.png" /></figure><h4>Save Bookmark</h4><p>Next, we need to use the AsyncStorage component from the React Native core package. For that, we can call from React Native directly Expo will continue to support this feature even it’s already deprecated from React Native core</p><pre>import {<br>    View,<br>    ScrollView,<br>    AsyncStorage, <br>    Share,<br>    TouchableOpacity,<br>} from &#39;react-native&#39;;</pre><p>Here, we are going to implement the saveBookMark function. For that, we need to define the function first as shown in the code snippet below:</p><pre>saveBookMark = async post_id =&gt; {<br>    this.setState({bookmark: true});<br>  };</pre><p>we have taken the parameter as post id. Then, we have set the bookmark state variable to true.</p><p>Now, we need to save the post id of the bookmarked post to the AsyncStorage. For that, we need to use the code from the following code snippet:</p><pre>saveBookMark = async post_id =&gt; {<br>         this.setState({bookmark: true});<br>         let bookmark = [];<br>         bookmark.push(post_id);<br>         AsyncStorage.setItem(&#39;bookmark&#39;, JSON.stringify(bookmark));<br>    <br> };</pre><p>Here, we have defined a new array called bookmark and pushed the post id value into it. Then, we have made use of the setItem function of the AsyncStorage to save the bookmark. We have saved the bookmark array as a JSON value.</p><p>Next, we need to prevent the duplicate bookmarks of the same article. For that, we need to use the code from the following code snippet:</p><pre>saveBookMark = async post_id =&gt; {<br>    this.setState({bookmark: true});<br>    await AsyncStorage.getItem(&#39;bookmark&#39;).then(token =&gt; {<br>      const res = JSON.parse(token);<br>      if (res !== null) {<br>        let data = res.find(value =&gt; value === post_id);<br>        if (data == null) {<br>          res.push(post_id);<br>          AsyncStorage.setItem(&#39;bookmark&#39;, JSON.stringify(res));<br>        }<br>      } else {<br>        let bookmark = [];<br>        bookmark.push(post_id);<br>         AsyncStorage.setItem(&#39;bookmark&#39;, JSON.stringify(bookmark));<br>      }<br>    });<br>  };</pre><p>Here, we get the bookmark data and then parse it to an array called res. Then, if we have the bookmark data, we search the post_id for the current post. If the post does not exist in the bookmark, then we can add the bookmark to it and prevent duplicate bookmarks. The third case is for the users who have not made any bookmarks yet. Hence, we can normally apply and save the bookmarks using the saveBookMark function.</p><h4>Summary</h4><p>In this chapter, we learned how to implement the UI and functionality of the bookmark button using the AsyncStorage module. Using it, we implemented the function to save method</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-9-saving-bookmark/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=712bc2592781" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-9-saving-bookmark-712bc2592781">Build React Native WordPress App [Expo way] #9 : Saving bookmark</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #8 : Share]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-8-share-2c39f5b198c4?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/2c39f5b198c4</guid>
            <category><![CDATA[react-native-share-data]]></category>
            <category><![CDATA[react-native-share-menu]]></category>
            <category><![CDATA[react-native-share-state]]></category>
            <category><![CDATA[react-native-share-image]]></category>
            <category><![CDATA[react-native-share-sheet]]></category>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Sun, 16 Feb 2020 16:52:45 GMT</pubDate>
            <atom:updated>2020-02-16T16:52:45.000Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SH3Cqg9KoZUmfrCX.png" /></figure><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p>in this chapter, we will set up a share component that helps we share the link with Native widget</p><pre>import {<br>  View,<br>  ScrollView,<br>  ActivityIndicator,<br>  Dimensions,<br>  Share,<br>  TouchableOpacity,<br>} from &#39;react-native&#39;;</pre><p>Then, we need to define a onShare function as shown in the code snippet below:</p><pre>onShare = async (title, uri) =&gt; {<br>    Share.share({<br>      title: title,<br>      url: uri,<br>    });<br>  };</pre><p>Here, we have used the share method from the Share component and provided the title and url of the article as parameters.</p><p>Now, we need to add the share button to the right side of the author section. For that, we need to use the code from the following code snippet:</p><pre>&lt;List.Item<br>     title={`${post[0]._embedded.author[0].name}`}<br>     description={`${post[0]._embedded.author[0].description}`}<br>      right={props =&gt; {<br>       return (<br>         &lt;TouchableOpacity<br>           onPress={() =&gt;<br>             this.onShare(post[0].title.rendered, post[0].link)<br>           }&gt;<br>           &lt;MaterialCommunityIcons name=&quot;share&quot; size={30} /&gt;<br>         &lt;/TouchableOpacity&gt;<br>       );<br>     }}</pre><p>we have used the right prop of the List component in order to return the template for the share button. The share button template contains the TouchableOpacity component which wraps the FontAwesome component with the share icon. The onShare function is called in the onPress event of the TouchableOpacity component. We also need to remember to import the FontAwesome icon bundle from the vector-icons package:</p><pre>import { MaterialCommunityIcons } from &#39;@expo/vector-icons&#39;;</pre><p>Now, we will get the following result in the emulators:</p><figure><img alt="Animated GIF" src="https://cdn-images-1.medium.com/max/350/0*7eH_jfri9xrVPjQA.gif" /></figure><h4>Summary</h4><p>In this chapter, we learned how to make use of Share component from the react-native package to implement the share button. Then, we also learned how to configure the Share component in order for the sharing screen to pop up in the screen. We made use of share() function provided by the Share component in order to display the sharing screen pop up. This allows us to share the article to the social accounts. Finally, we implemented the share button using the vector icon as well.</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-8-share/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c39f5b198c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-8-share-2c39f5b198c4">Build React Native WordPress App [Expo way] #8 : Share</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #7 : Single Post screen]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-7-single-post-screen-7e845d1c6660?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/7e845d1c6660</guid>
            <category><![CDATA[react-native-html-parser]]></category>
            <category><![CDATA[react-native-html-table]]></category>
            <category><![CDATA[react-native-html-to-pdf]]></category>
            <category><![CDATA[react-native-html-editor]]></category>
            <category><![CDATA[react-native-render-html]]></category>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Sun, 16 Feb 2020 16:13:40 GMT</pubDate>
            <atom:updated>2020-02-16T16:13:40.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_N94tO64uvOOHk-q.png" /></figure><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p>this chapter we wrap around card item with TouchableOpacity when user touch this post will navigate to single post with post id</p><pre>&lt;TouchableOpacity<br> onPress={() =&gt;<br>   this.props.navigation.navigate(&#39;SinglePost&#39;, {<br>     post_id: item.id,<br>   })<br> }&gt;<br> &lt;Card<br>   style={{<br>     shadowOffset: {width: 5, height: 5},<br>     width: &#39;90%&#39;,<br>     borderRadius: 12,<br>     alignSelf: &#39;center&#39;,<br>     marginBottom: 10,<br>   }}&gt;<br>  .................................. // other code<br> &lt;/Card&gt;<br> &lt;/TouchableOpacity&gt;</pre><p>for now, we already have blank scree that we create from the last chapter</p><h4>React native paper</h4><p>first, we import react-native-paper component and set</p><pre>import React from &#39;react&#39;;<br>import {<br>    Avatar,<br>    Button,<br>    Card,<br>    Title,<br>    Paragraph,<br>    List,<br>} from &#39;react-native-paper&#39;;<br>import HTML from &#39;react-native-htmlview&#39;;<br>import {<br>    View,<br>    ScrollView,<br>    ActivityIndicator<br>} from &#39;react-native&#39;;<br>import moment from &#39;moment&#39;;</pre><p>then add function for call data from API</p><pre>export default class SinglePost extends React.Component {<br>    constructor(props) {<br>        super(props);<br><br>        this.state = {<br>            isloading: true,<br>            post: [],<br>        };<br>    }<br><br>    componentDidMount() {<br>        this.fetchPost();<br>    }<br>    async fetchPost() {<br>        let post_id = this.props.route.params?.post_id<br><br>        const response = await fetch(<br>            `https://kriss.io/wp-json/wp/v2/posts?_embed&amp;include=${post_id}`<br>        );<br>        const post = await response.json();<br>        this.setState({<br>            post: post,<br>            isloading: false,<br>        });<br>    }</pre><p>if you using react-navigation version 4 before will spot on params? is a new method for getting param</p><p>then we construct screen with react native paper component again</p><pre>render() {<br>        let post = this.state.post;<br>        }<br>        return (<br>            &lt;ScrollView&gt;<br>                &lt;Card&gt;<br>                    &lt;Card.Content&gt;<br>                        &lt;Title&gt;{post[0].title.rendered} &lt;/Title&gt;<br>                        &lt;List.Item<br>                            title={`${post[0]._embedded.author[0].name}`}<br>                            description={`${post[0]._embedded.author[0].description}`}<br>                            left={props =&gt; {<br>                                return (<br>                                    &lt;Avatar.Image<br>                                        size={55}<br>                                        source={{<br>                                            uri: `${post[0]._embedded.author[0].avatar_urls[96]}`,<br>                                        }}<br>                                    /&gt;<br>                                );<br>                            }}<br>                        /&gt;<br>                        &lt;List.Item<br>                            title={`Published on ${moment(<br>                                post[0].date,<br>                                &#39;YYYYMMDD&#39;<br>                            ).fromNow()}`}<br>                        /&gt;<br>                        &lt;Paragraph /&gt;<br>                    &lt;/Card.Content&gt;<br>                    &lt;Card.Cover source={{ uri: post[0].jetpack_featured_media_url }} /&gt;<br>                    &lt;Card.Content&gt;<br>                        &lt;HTML value={post[0].content.rendered} addLineBreaks={false} /&gt;<br>                    &lt;/Card.Content&gt;<br>                &lt;/Card&gt;<br>            &lt;/ScrollView&gt;<br>        );<br>}</pre><p>here for result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/0*sGTC1k2HknrKbcEb.png" /></figure><h4>Add placeholder</h4><p>for the last feature, we add placeholder like Home screen first import content placeholder component</p><pre>render() {<br>    let post = this.state.post;<br>    if (this.state.isloading) {<br>        return &lt;ContentPlaceholder /&gt;;<br>    }<br>    return (<br>        &lt;ScrollView&gt; .....<br>    );<br>}</pre><p>here will see result same Home screen</p><figure><img alt="Animated GIF" src="https://cdn-images-1.medium.com/max/270/0*pxIBpLdmxCqTIWaq.gif" /></figure><h4>summary</h4><p>In this chapter, we learned how to implement the overall UI of the SinglePost screen. First, we learned how to set up the navigation to the SinglePost screen by clicking on any article post from the home screen list. The SinglePost screen displays the overall content of the single article. We used different components from react-native-paper in order to implement the UI. We also made use of the moment and react-native-htmlview package on this screen. Lastly, we learned how to fetch the data of the single article post from the WordPress API using the fetch function.last thing we wrap screen with Content placeholder same Home screen again</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-7-single-post-screen/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e845d1c6660" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-7-single-post-screen-7e845d1c6660">Build React Native WordPress App [Expo way] #7 : Single Post screen</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #6 : image and content placeholder]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-6-image-and-content-placeholder-42bd11534f68?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/42bd11534f68</guid>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Sun, 16 Feb 2020 14:40:14 GMT</pubDate>
            <atom:updated>2020-02-16T14:40:14.183Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d5lPU-n-Vvye4tVK.png" /></figure><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p>this chapter we want to inform user for content being load and will show soon with Rnplaceholder package then we add image place holder again with react-native-image-placeholder is simple and need a little work but make good user experience take they not seen a blank screen</p><h4>Content placeholder</h4><p>import package to Home.js</p><pre>import {<br>  Placeholder,<br>  PlaceholderMedia,<br>  PlaceholderLine,<br>  Fade<br>} from &quot;rn-placeholder&quot;;</pre><p>then change render function</p><pre>render() {<br>    if (this.state.isLoading) {<br>      return (<br>        &lt;View style={{ marginTop: 23, padding: 33 }}&gt;<br>          &lt;RNPlaceHolder /&gt;<br>        &lt;/View&gt;<br>      );<br>    } else {</pre><p>while isLoading equal true we display placeholder we can adjust placeholder style whatever your want all example available on <a href="https://snack.expo.io/@mfrachet/84bb31">snack</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*cUKAZCL5fRowG5pt.gif" /></figure><p>your will see simple demo for make nice we can add more row like that</p><figure><img alt="Animated GIF" src="https://cdn-images-1.medium.com/max/350/0*zeliSJbYE61L6rlP.gif" /></figure><p>but we got a lot of repeats code</p><pre>&lt;View style={{ marginTop: 23, padding: 33 }}&gt;<br>                   &lt;Placeholder<br>                       Animation={Fade}<br>                       Left={PlaceholderMedia}<br>                       Right={PlaceholderMedia}<br>                   &gt;<br>                       &lt;PlaceholderLine width={80} /&gt;<br>                       &lt;PlaceholderLine /&gt;<br>                       &lt;PlaceholderLine width={30} /&gt;<br>                       <br>                   &lt;/Placeholder&gt;<br>                   &lt;Placeholder<br>                       Animation={Fade}<br>                       Left={PlaceholderMedia}<br>                       Right={PlaceholderMedia}<br>                   &gt;<br>                       &lt;PlaceholderLine width={80} /&gt;<br>                       &lt;PlaceholderLine /&gt;<br>                       &lt;PlaceholderLine width={30} /&gt;<br>                       <br>                   &lt;/Placeholder&gt;<br>                   &lt;Placeholder<br>                       Animation={Fade}<br>                       Left={PlaceholderMedia}<br>                       Right={PlaceholderMedia}<br>                   &gt;<br>                       &lt;PlaceholderLine width={80} /&gt;<br>                       &lt;PlaceholderLine /&gt;<br>                       &lt;PlaceholderLine width={30} /&gt;<br>                       <br>                   &lt;/Placeholder&gt;<br>                   &lt;Placeholder<br>                       Animation={Fade}<br>                       Left={PlaceholderMedia}<br>                       Right={PlaceholderMedia}<br>                   &gt;<br>                       &lt;PlaceholderLine width={80} /&gt;<br>                       &lt;PlaceholderLine /&gt;<br>                       &lt;PlaceholderLine width={30} /&gt;<br>                       <br>                   &lt;/Placeholder&gt;<br>                   <br>                   &lt;Placeholder<br>                       Animation={Fade}<br>                       Left={PlaceholderMedia}<br>                       Right={PlaceholderMedia}<br>                   &gt;<br>                       &lt;PlaceholderLine width={80} /&gt;<br>                       &lt;PlaceholderLine /&gt;<br>                       &lt;PlaceholderLine width={30} /&gt;<br>                       <br>                   &lt;/Placeholder&gt;<br>                   &lt;Placeholder<br>                       Animation={Fade}<br>                       Left={PlaceholderMedia}<br>                       Right={PlaceholderMedia}<br>                   &gt;<br>                       &lt;PlaceholderLine width={80} /&gt;<br>                       &lt;PlaceholderLine /&gt;<br>                       &lt;PlaceholderLine width={30} /&gt;<br>                       <br>                   &lt;/Placeholder&gt;<br>                   &lt;Placeholder<br>                       Animation={Fade}<br>                       Left={PlaceholderMedia}<br>                       Right={PlaceholderMedia}<br>                   &gt;<br>                       &lt;PlaceholderLine width={80} /&gt;<br>                       &lt;PlaceholderLine /&gt;<br>                       &lt;PlaceholderLine width={30} /&gt;<br>                       <br>                   &lt;/Placeholder&gt;<br>                   &lt;Placeholder<br>                       Animation={Fade}<br>                       Left={PlaceholderMedia}<br>                       Right={PlaceholderMedia}<br>                   &gt;<br>                       &lt;PlaceholderLine width={80} /&gt;<br>                       &lt;PlaceholderLine /&gt;<br>                       &lt;PlaceholderLine width={30} /&gt;<br>                       <br>                   &lt;/Placeholder&gt;</pre><p>we can separate to component</p><pre>import React, { Component } from &#39;react&#39;<br>import { Text, View } from &#39;react-native&#39;<br>import { Placeholder, PlaceholderMedia, PlaceholderLine, Fade } from &quot;rn-placeholder&quot;;<br><br>export class ContentPlaceholder extends Component {<br>    render() {<br>        return (<br>            &lt;View style={{ marginTop: 23, padding: 33 }}&gt;<br>                &lt;Placeholder<br>                    Animation={Fade}<br>                    Left={PlaceholderMedia}<br>                    Right={PlaceholderMedia}<br>                &gt;<br>                    &lt;PlaceholderLine width={80} /&gt;<br>                    &lt;PlaceholderLine /&gt;<br>                    &lt;PlaceholderLine width={30} /&gt;<br><br>                &lt;/Placeholder&gt;<br>                &lt;Placeholder<br>                    Animation={Fade}<br>                    Left={PlaceholderMedia}<br>                    Right={PlaceholderMedia}<br>                &gt;<br>                    &lt;PlaceholderLine width={80} /&gt;<br>                    &lt;PlaceholderLine /&gt;<br>                    &lt;PlaceholderLine width={30} /&gt;<br><br>                &lt;/Placeholder&gt;<br>                &lt;Placeholder<br>                    Animation={Fade}<br>                    Left={PlaceholderMedia}<br>                    Right={PlaceholderMedia}<br>                &gt;<br>                    &lt;PlaceholderLine width={80} /&gt;<br>                    &lt;PlaceholderLine /&gt;<br>                    &lt;PlaceholderLine width={30} /&gt;<br><br>                &lt;/Placeholder&gt;<br>                &lt;Placeholder<br>                    Animation={Fade}<br>                    Left={PlaceholderMedia}<br>                    Right={PlaceholderMedia}<br>                &gt;<br>                    &lt;PlaceholderLine width={80} /&gt;<br>                    &lt;PlaceholderLine /&gt;<br>                    &lt;PlaceholderLine width={30} /&gt;<br><br>                &lt;/Placeholder&gt;<br><br>                &lt;Placeholder<br>                    Animation={Fade}<br>                    Left={PlaceholderMedia}<br>                    Right={PlaceholderMedia}<br>                &gt;<br>                    &lt;PlaceholderLine width={80} /&gt;<br>                    &lt;PlaceholderLine /&gt;<br>                    &lt;PlaceholderLine width={30} /&gt;<br><br>                &lt;/Placeholder&gt;<br>                &lt;Placeholder<br>                    Animation={Fade}<br>                    Left={PlaceholderMedia}<br>                    Right={PlaceholderMedia}<br>                &gt;<br>                    &lt;PlaceholderLine width={80} /&gt;<br>                    &lt;PlaceholderLine /&gt;<br>                    &lt;PlaceholderLine width={30} /&gt;<br><br>                &lt;/Placeholder&gt;<br>                &lt;Placeholder<br>                    Animation={Fade}<br>                    Left={PlaceholderMedia}<br>                    Right={PlaceholderMedia}<br>                &gt;<br>                    &lt;PlaceholderLine width={80} /&gt;<br>                    &lt;PlaceholderLine /&gt;<br>                    &lt;PlaceholderLine width={30} /&gt;<br><br>                &lt;/Placeholder&gt;<br>                &lt;Placeholder<br>                    Animation={Fade}<br>                    Left={PlaceholderMedia}<br>                    Right={PlaceholderMedia}<br>                &gt;<br>                    &lt;PlaceholderLine width={80} /&gt;<br>                    &lt;PlaceholderLine /&gt;<br>                    &lt;PlaceholderLine width={30} /&gt;<br><br>                &lt;/Placeholder&gt;<br>            &lt;/View&gt;<br>        )<br>    }<br>}<br><br>export default ContentPlaceholder</pre><p>last, add back to Home.js</p><pre>import ContentPlaceholder from &#39;../components/ContentPlaceholder&#39;</pre><p>then replace old code</p><pre>if (this.state.isFetching) {<br>         return &lt;ContentPlaceholder /&gt;;<br>     } else {</pre><p>now we can use on another screen for the next chapter</p><h4>Image placeholder</h4><p>next, we add another placeholder for image even another component showing after content placeholder disappear but an image will not load success for this we add another <a href="https://github.com/mfrachet/rn-placeholder">image placeholder</a> package</p><pre>npm i --save react-native-image-placeholder</pre><p>then import package</p><pre>import ImageLoad from &#39;react-native-image-placeholder&#39;;</pre><p>and replace old card cover component</p><pre>&lt;ImageLoad<br>    style={{ width: &#39;100%&#39;, height: 300 }}<br>    loadingStyle={{ size: &#39;large&#39;, color: &#39;blue&#39; }}<br>    source={{ uri: item.jetpack_featured_media_url }}<br>/&gt;</pre><p>your will see result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*gp8N-M0s2WP1GyH9.gif" /></figure><p>next your can add for every screen that wants to initial make HTTP request</p><h4>Conclusion</h4><p>we successfully add a placeholder to our app that makes look nice and better for the next chapter. We will implement a single post screen to show individual post</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-6-image-and-content-placeholder/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42bd11534f68" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-6-image-and-content-placeholder-42bd11534f68">Build React Native WordPress App [Expo way] #6 : image and content placeholder</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build React Native WordPress App [Expo way] #5 : Pull To Refresh and Infinite scroll]]></title>
            <link>https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-5-pull-to-refresh-and-infinite-scroll-e8a5fb126dfe?source=rss----e7ad1fe38ced---4</link>
            <guid isPermaLink="false">https://medium.com/p/e8a5fb126dfe</guid>
            <category><![CDATA[react-native-flatlist-key]]></category>
            <dc:creator><![CDATA[Krissanawat Kaewsanmuang]]></dc:creator>
            <pubDate>Sat, 15 Feb 2020 16:41:50 GMT</pubDate>
            <atom:updated>2020-02-15T16:41:49.981Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L0qJWlru3ifkFUO8.png" /></figure><p>This series intends to show how I build an app to serve content from my WordPress blog by using react-native. Since we successfully build an app on the React Native CLI path., for the next step, we try to develop this app again but using Expo. We will discover the Expo ecosystem that makes our lives comfortable and help us avoid dealing with Native modules to learn how to deal with WordPress APIs. Here, the most prominent features talked about in the book are the dark theme, offline mode, infinite scroll, in-app purchase, and many more. You can discover much more in this series. this inspiration to do this tutorial series came from the <a href="http://instamobile.io/">React Native Templates</a> from instamobile</p><p>here we continued from the previous chapter that we did on the necessary HTTP request in this section we are going to implement a pull to refresh and infinite scroll that makes Home screen more feature two feature is simple because Flatlist provide comfortable</p><h4>Pull to refresh</h4><p>for pull to refresh is we hit long-press and scroll down that make the event for make API request again. We need to define a state variable called <strong>isFetching,</strong> which will handle the hiding and showing of refresh loader. like the code snippet below:</p><pre>this.state = { <br>     posts:[],<br>     isFetching: false,<br>  }</pre><p>Next, we need to create a function called onRefresh() which will trigger when we pull the pull to refresh the trigger.</p><pre>onRefresh() { <br>  this.setState({ <br>     isFetching: true <br>  }, <br>  function() { <br>     this.fetchLastestPost()<br>   }); <br>}</pre><p>Here, we have changed the state of to true and also called the fetchLastestPost function again. This will cause the re-fetch of the posts by making an API call to the server.</p><p>Now, we need to add the onRefresh function to the onRefresh event of the FlatList as shown in the code snippet below:</p><pre>&lt;FlatList <br>  data={ this.state.posts }<br>  onRefresh={() =&gt; this.onRefresh()} <br>  refreshing={this.state.isFetching}</pre><p>And, in the fetchLastestPost function, we also need to change the state of isFetching too false to hide the scroll loader.</p><pre>async fetchLastestPost() { <br>  const response = await fetch(&#39;https://kriss.io/wp-json/wp/v2/posts?per_page=5&#39;); <br>  const posts = await response.json(); <br>  this.setState({ posts: posts, isFetching: false}); <br>}</pre><p>and will try pull to refresh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*yg_4bZ1qNR3EZw9V.gif" /></figure><h4>Infinite scroll</h4><p>for last in this chapter, we implement infinite scroll that like load more feature when user scroll reach the end of last flatlist item we will make API call for next post item like pagination on a web.</p><p>first, we add state for handle page</p><pre>this.state = { <br> posts:[], <br> isFetching: false, <br> page: 1<br>}</pre><p>Next, we are going to create a new function called <strong>handleLoadMore</strong> and call it in the <strong>onEndReached</strong> event of the FlatList. We are also configuring some additional props to the FlatList such as <strong>onEndReachedThreshold</strong> which controls the trigger of function based on how far we are from the bottom of the list. The overall implementation is provided in the code snippet below:</p><pre>onEndReached={this.handleLoadMore}<br>onEndReachedThreshold={0.1}<br>ListFooterComponent={this.renderFooter}</pre><p>Now, the add <strong>handleLoadMore</strong> function is provided in the code snippet below:</p><pre>handleLoadMore = () =&gt; {<br>    this.setState(<br>      {<br>        page: this.state.page + 1,<br>      },<br>      () =&gt; {<br>        this.fetchLastestPost();<br>      },<br>    );<br>  };</pre><p>Here, we have made increment to the page state variable after then called the fetchLastestPost() function again.</p><p>Next, we need to make some configuration in the fetching of API as well which will be based on the page number as shown in the code snippet below:</p><pre>async fetchLastestPost() {<br>    let page = this.state.page;<br>    const response = await fetch(<br>      `https://kriss.io/wp-json/wp/v2/posts?per_page=5&amp;page=${page}`,<br>    );<br>    const posts = await response.json();<br>    this.setState({<br>      posts: page === 1 ? posts : [...this.state.posts, ...posts],<br>      isFetching: false,<br>    });<br>  }</pre><p>first, we add page counter to URL that makes load next data set for every new request</p><p>second for append new post to state</p><p>last thing we add an Activity indicator for show load new data</p><pre>renderFooter = () =&gt; {<br>    if (this.state.isFetching) return null;<br>    return (<br>      &lt;View<br>        style={{<br>          paddingVertical: 20,<br>          borderTopWidth: 1,<br>          borderColor: &quot;#CED0CE&quot;<br>        }}<br>      &gt;<br>        &lt;ActivityIndicator animating size=&quot;large&quot; /&gt;<br>      &lt;/View&gt;<br>    );<br>  };</pre><p>now we see the result while test by your self</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*o0wRTUdYLAKQVypj.gif" /></figure><h4>Conclusion</h4><p>this chapter we learn to implement two main feature of Flatlist pull to refresh and infinite scroll that simple . for next chapter we will implement loading place holder that show before API call success</p><p><em>Originally published at </em><a href="https://kriss.io/build-react-native-wordpress-app-expo-way-5-pull-to-refresh-and-infinite-scroll/"><em>Kriss</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8a5fb126dfe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-mastery/build-react-native-wordpress-app-expo-way-5-pull-to-refresh-and-infinite-scroll-e8a5fb126dfe">Build React Native WordPress App [Expo way] #5 : Pull To Refresh and Infinite scroll</a> was originally published in <a href="https://medium.com/react-native-mastery">React Native Mastery</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>