<?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[Stories by Merve Dilek on Medium]]></title>
        <description><![CDATA[Stories by Merve Dilek on Medium]]></description>
        <link>https://medium.com/@mervedilek?source=rss-3351ae40098a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JkEFBI-fFznD2AmGFBAN6Q.jpeg</url>
            <title>Stories by Merve Dilek on Medium</title>
            <link>https://medium.com/@mervedilek?source=rss-3351ae40098a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 08:57:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mervedilek/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Redux-Thunk (usage with redux-toolkit)]]></title>
            <link>https://mervedilek.medium.com/redux-thunk-usage-with-redux-toolkit-2983a8fea0ad?source=rss-3351ae40098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2983a8fea0ad</guid>
            <dc:creator><![CDATA[Merve Dilek]]></dc:creator>
            <pubDate>Mon, 12 Jun 2023 11:57:23 GMT</pubDate>
            <atom:updated>2023-06-12T11:57:23.863Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*z-eMxn2LD4aZkUGkGXd2YQ.jpeg" /></figure><p>Although actions in Redux sound like they do the actions, they are just plain objects. Redux-Thunk is a middleware that allows action creators to be functions. Moreover, Redux-Thunk also enables the action creator functions to be not pure functions, in other words those functions can have side effects possibly involving in asynchronous API calls. While it provides a way to make them asynchronous functions, reducers still stay synchronous.</p><p>Thunk functions can delay actions until some events occur. They return <strong>functions</strong> which return actions, rather than returning actions immediately. We can delay dispatching of an action until some http events happen with the help of Redux-Thunk.</p><p>I used redux-toolkit in my example project ( I will give more details in another story about redux-toolkit) which provides easiness in writing redux projects and also speeds up the development.</p><p>Redux toolkit creates action creators automatically with reducer methods. While generating thunk functions, our return function should receive dispatch as a parameter. With dispatch parameter we can dispatch the actions we want to perform, before or after some asynchronous events and side effects.</p><p>In the example below, we have a counter and an information bar. When we change the counter, we update our counter value on firebase database and when the fetch operation finishes, we update our notification according to the status which is maintained by redux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JF77KXUo1WmvxLyRMREwLg.gif" /></figure><p>App.js</p><pre>import &quot;./App.css&quot;;<br>import Counter from &quot;./components/Counter&quot;;<br>import StatusBar from &quot;./components/StatusBar&quot;;<br><br>function App() {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;Counter /&gt;<br>      &lt;StatusBar /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p><strong>redux store files</strong></p><p>index.js</p><pre>import { configureStore } from &#39;@reduxjs/toolkit&#39;;<br><br>import counterSlice from &#39;./counter-slice&#39;;<br>import notificationSlice from &#39;./notification-slice&#39;;<br><br>const store = configureStore({<br>  reducer: { counter: counterSlice.reducer, notification: notificationSlice.reducer },<br>});<br><br>export default store;</pre><p><strong>counter-slice.js</strong></p><pre>import { createSlice } from &quot;@reduxjs/toolkit&quot;;<br>import { notificationActions } from &quot;./notification-slice&quot;;<br><br>const counterSlice = createSlice({<br>  name: &quot;counter&quot;,<br>  initialState: {<br>    value: 0,<br>  },<br>  reducers: {<br>    updateCounter(state, action) {<br>      if (action.payload === &quot;inc&quot;) {<br>        state.value++;<br>      } else if (action.payload === &quot;dec&quot;) {<br>        state.value--;<br>      }<br>    },<br>  },<br>});<br><br>export const changeCounter = (val, type) =&gt; {<br>  return async (dispatch) =&gt; {<br>    dispatch(notificationActions.updateNotification(&quot;sending&quot;));<br>    const sendReq = async () =&gt; {<br>      const response = await fetch(<br>        &quot;https://mediumprojects-f255b-default-rtdb.firebaseio.com/counter.json&quot;,<br>        {<br>          method: &quot;PUT&quot;,<br>          body: JSON.stringify({ value: val }),<br>        }<br>      );<br>      if (!response.ok) {<br>        throw new Error(&quot;Sending counter value failed.&quot;);<br>      }<br>    };<br>    try {<br>      await sendReq();<br>      dispatch(counterActions.updateCounter(type));<br>      dispatch(notificationActions.updateNotification(&quot;sent&quot;));<br>    } catch (error) {<br>      notificationActions.updateNotification(&quot;error&quot;);<br>    }<br>  };<br>};<br><br>export const counterActions = counterSlice.actions;<br>export default counterSlice;</pre><p>notification-slice.js</p><pre>import { createSlice } from &quot;@reduxjs/toolkit&quot;;<br><br>const notificationSlice = createSlice({<br>  name: &quot;notification&quot;,<br>  initialState: {<br>    status: null<br>  },<br>  reducers: {<br>    updateNotification(state, action) {<br>      state.status = action.payload;<br>    },<br>  },<br>});<br><br>export const notificationActions = notificationSlice.actions;<br>export default notificationSlice;</pre><p>Counter.js</p><pre>import classes from &quot;./Counter.module.css&quot;;<br><br>import { useSelector, useDispatch } from &quot;react-redux&quot;;<br>import { changeCounter } from &quot;../store/counter-slice&quot;;<br><br>const Counter = (props) =&gt; {<br>  const counter = useSelector((state) =&gt; state.counter);<br>  const dispatch = useDispatch();<br>  return (<br>    &lt;div className={classes.content}&gt;<br>      &lt;div className={classes.buttons}&gt;<br>        &lt;button<br>          className={classes.button}<br>          onClick={() =&gt; {<br>            dispatch(changeCounter(counter.value + 1, &quot;inc&quot;));<br>          }}<br>        &gt;<br>          increment<br>        &lt;/button&gt;<br>        &lt;button<br>          className={classes.button}<br>          onClick={() =&gt; {<br>            dispatch(changeCounter(counter.value - 1, &quot;dec&quot;));<br>          }}<br>        &gt;<br>          decrement<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br>      &lt;div className={classes.counter}&gt;counter: {counter.value}&lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default Counter;</pre><p>StatusBar.js</p><pre>import { useSelector } from &quot;react-redux&quot;;<br><br>import classes from &quot;./StatusBar.module.css&quot;;<br><br>const StatusBar = (props) =&gt; {<br>  const notification = useSelector((state) =&gt; state.notification);<br>  return &lt;div className={classes.status}&gt;{notification.status}&lt;/div&gt;;<br>};<br><br>export default StatusBar;</pre><p>You can find the whole project on github<br><a href="https://github.com/sagmer/redux-thunk">https://github.com/sagmer/redux-thunk</a></p><p>Thank you for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2983a8fea0ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[useReducer Function – React]]></title>
            <link>https://mervedilek.medium.com/usereducer-function-react-16750886de1d?source=rss-3351ae40098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/16750886de1d</guid>
            <dc:creator><![CDATA[Merve Dilek]]></dc:creator>
            <pubDate>Sat, 03 Jun 2023 09:25:44 GMT</pubDate>
            <atom:updated>2023-06-03T09:25:44.955Z</atom:updated>
            <content:encoded><![CDATA[<p>useReducer Function – React</p><p>useReducer function in React, which is not related to redux (although it has a similar logic), is used for a state management, especially if we have multiple states connected to each other or a complex state to manage and update.</p><p>the structure of useReducer function is as follows:</p><p>const [state, dispatchFunction] = useReducer (reducerFunction, initialState, initialFunction(for complex states, not used generally))</p><ul><li>“state” value in return array is the latest state</li><li>“dispatchFunction” dispatches an action, which will be consumed by reducerFunction and the state is updated accordingly.</li></ul><p>the structure of reducerFunction as follows:<br> reducerFunction = (prevState, action) =&gt; newState</p><p>It takes previous state and the action dispatched by dispatchFunction, and the newState is returned by this function.</p><p>Although using useReducer is not a must, there are some cases which can be judged it is better to use. I will give such an example.</p><p>In the example, two states connected to each other will be managed by useReducer() function. Keep in my mind that you can use two different useState() functions.</p><p>In the example below, two different actions are dispatched by input blur and input change events. For every keystroke on e-mail input, INPUT_CHANGE action is dispatched, which changes both e-mail value and isValid fields, whereas INPUT_BLUR action only updates isValid field, while keeping value the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*bsqMPO5X_RUEsioOtediXg.gif" /></figure><pre>import React, { useReducer } from &quot;react&quot;;<br>import classes from &quot;./Login.module.css&quot;;<br><br>const emailReducer = (state, action) =&gt; {<br>  const validRegex =<br>    /^(([^&lt;&gt;()[\]\\.,;:\s@&quot;]+(\.[^&lt;&gt;()[\]\\.,;:\s@&quot;]+)*)|.(&quot;.+&quot;))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{3,}))$/;<br>  if (action.type === &quot;INPUT_CHANGE&quot;) {<br>    return {<br>      value: action.val,<br>      isValid: action.value.match(validRegex) ? true : false,<br>    };<br>  }<br>  if (action.type === &quot;INPUT_BLUR&quot;) {<br>    return {<br>      value: state.value,<br>      isValid: action.value.match(validRegex) ? true : false,<br>    };<br>  }<br>  return {<br>    value: state.value,<br>    isValid: state.isValid,<br>  };<br>};<br><br>const Login = (props) =&gt; {<br>  const [emailState, dispatchEmail] = useReducer(emailReducer, {<br>    value: &quot;&quot;,<br>    isValid: false,<br>  });<br><br>  const inputBlurHandler = (event) =&gt; {<br>    dispatchEmail({ type: &quot;INPUT_BLUR&quot;, value: event.target.value });<br>  };<br>  const inputChangeHandler = (event) =&gt; {<br>    dispatchEmail({ type: &quot;INPUT_CHANGE&quot;, value: event.target.value });<br>  };<br>  return (<br>    &lt;div className={classes.form}&gt;<br>      &lt;div className={classes.label}&gt;e-mail&lt;/div&gt;<br>      &lt;div className={classes.inputGroup}&gt;<br>        &lt;input<br>          onBlur={inputBlurHandler}<br>          onChange={inputChangeHandler}<br>          className={classes.input}<br>        /&gt;<br>        &lt;div className={emailState.isValid ? classes.label : classes.invalid}&gt;<br>          {emailState.isValid<br>            ? &quot;valid e-mail&quot;<br>            : &quot;please enter a valid e-mail address&quot;}<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>      &lt;div className={classes.label}&gt;name&lt;/div&gt;<br>      &lt;input className={classes.input} /&gt;<br>      &lt;button&gt;OK&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default Login;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16750886de1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why and How to use useCallback and React.memo]]></title>
            <link>https://mervedilek.medium.com/why-and-how-to-use-usecallback-and-react-memo-77dc513c044c?source=rss-3351ae40098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/77dc513c044c</guid>
            <category><![CDATA[memoization]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[callback]]></category>
            <category><![CDATA[memo]]></category>
            <dc:creator><![CDATA[Merve Dilek]]></dc:creator>
            <pubDate>Wed, 28 Oct 2020 08:58:36 GMT</pubDate>
            <atom:updated>2020-10-28T08:58:36.101Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*X0pjT7rKG8SALwKtDaX43g.png" /></figure><p>useCallback<em> </em>function is used to prevent or restrict the re-creation of functions. One common case is using this function with React.memo (or shouldComponentUpdate in class based components) to improve the performance issues. This is especially crucial during rendering of large number of components needlessly.</p><p>In theory, we can use the trick mentioned above every time, but it does not always bring an optimal solution to performance. Be aware that there is an overhead of checking props for change in child components when memo or shouldComponentUpdate is used. Therefore the decision to prevent unnecessary renders of child components should only be applied when we are sure it will pay off.</p><p>In this story, I will give a simple React-Native example to show the effect of useCallback when it is used with memo in order to eliminate unnecessary renders of child components.</p><p>In the following example, a parent functional component has two different functions to be passed as parameters to its child components. While one of the methods is wrapped by useCallback, the other function is not. Second child component takes the function wrapped by useCallback as a parameter and uses memo internally to discard re-rendering as long as props passed by parent do not change. That’s what we want!</p><p>Both the parent component and children components hold a counter state and increments it via button clicks. The parent component also passes a button press handler function to be invoked when child components’ counter incrementing buttons are clicked.</p><p>Counter state change on parent component causes parent component to re-render. On each render, functions of parent component will be recreated if they are not wrapped by useCallback. This results in a re-rendering of the first child component whenever the parent’s counter change, since it receives a different buttonPress (child1ButtonPress below in code snippet) function as prop each time parent renders. This is not the case for the second child component since it is always passed the same buttonPress (child2ButtonPress below in code snippet) function as prop, which is created only in the first rendering of the parent.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02cc288ec940861c09f5e9e229cfb485/href">https://medium.com/media/02cc288ec940861c09f5e9e229cfb485/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d9d2ec3388e9aabd7abb41d329a8bbc/href">https://medium.com/media/6d9d2ec3388e9aabd7abb41d329a8bbc/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d56920e477c40ec2a3f7464da23da8d3/href">https://medium.com/media/d56920e477c40ec2a3f7464da23da8d3/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*4fhjApH2A_Ib2bsp7Yv-qw.gif" /><figcaption>Demo run</figcaption></figure><p>As can be seen in Demo Run above, Child1 is rendered each time parent re-renders; but it is not the case for Child2 thanks to using useCallback for press handler in parent and memo within the child itself. You can reach the whole code from following <a href="https://github.com/sagmer/CallbackExample">github repository</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77dc513c044c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding Listener to Drawer Navigator Routes]]></title>
            <link>https://mervedilek.medium.com/adding-listener-to-drawer-navigator-routes-eb6deefc2cf4?source=rss-3351ae40098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb6deefc2cf4</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[listener]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[navigation-drawer]]></category>
            <dc:creator><![CDATA[Merve Dilek]]></dc:creator>
            <pubDate>Thu, 08 Oct 2020 13:29:58 GMT</pubDate>
            <atom:updated>2020-10-15T08:21:27.254Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*i2-p4NrkYDigLvA90fddtg.png" /></figure><p><strong>Adding Listener to Drawer Navigator Routes</strong></p><p>Unlike stack navigators, screens of drawer navigators are not destroyed and recreated, when the user close and re-opens these screens. These may cause some problems like the data is not updated although the component is rendered. These kind of problems can be solved by adding listeners to the routes of drawer navigators.</p><p>We can illustrate this situation with a simple example. Suppose ScreenA and ScreenB are the route components of your drawer navigator. Each component has a counter value initialized to 0, and a function that increments the counter value by 1. While ScreenA calls this function in its body part, ScreenB calls it when it is focused which is achieved by adding a navigation listener.</p><p>When we navigate between these screens of drawer navigator, while counter value remains the same in ScreenA, increment function runs on ScreenB thanks to listener.</p><p>MainNavigator.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d512059ab9e7a26ea7c7028f0efc2511/href">https://medium.com/media/d512059ab9e7a26ea7c7028f0efc2511/href</a></iframe><p>ScreenA.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b816f84dd584bc8950dac2dd7c41b00e/href">https://medium.com/media/b816f84dd584bc8950dac2dd7c41b00e/href</a></iframe><p>ScreenB.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b257d2d418b35c08d296804554f8aa3/href">https://medium.com/media/5b257d2d418b35c08d296804554f8aa3/href</a></iframe><p>the output when we navigate from ScreenA to ScreenB, and again to ScreenA mutliple times:</p><pre>Screen A counter is 1<br>Screen B counter is 0<br>Screen B counter is 1<br>Screen B counter is 2</pre><p>You can download and try the example from the following link:</p><blockquote><a href="https://github.com/sagmer/Examples_Navigation">https://github.com/sagmer/Examples_Navigation</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb6deefc2cf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending Dynamically Changing Parameters from Functional Component to Navigation Options]]></title>
            <link>https://mervedilek.medium.com/sending-dynamically-changing-parameters-from-functional-component-to-navigation-options-fb95766ca89a?source=rss-3351ae40098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb95766ca89a</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[usecallback]]></category>
            <dc:creator><![CDATA[Merve Dilek]]></dc:creator>
            <pubDate>Tue, 22 Sep 2020 11:34:26 GMT</pubDate>
            <atom:updated>2020-10-21T19:34:53.420Z</atom:updated>
            <content:encoded><![CDATA[<p>In functional component’s navigation settings, we cannot take dynamically changing parameters directly from navigation data.</p><p>Suppose a functional component has a header button which takes information entered by user. In order to get the latest information given by the user, by using setParams() function, parameters can be passed to navigation options when user enters these values.</p><pre>import React,{useState, useEffect, useCallback} from “react”;<br>import {TextInput} from “react-native”;</pre><pre>const foo = props =&gt; {</pre><pre>   const [name, setName]=useState(“”);<br>   const handlerFunc=useCallback(()=&gt;{      <br>        //when header button is pressed<br>   },[name]) //never be recreated to avoid infinite loop</pre><pre>   useEffect(()=&gt;      {props.navigation.<strong>setParams</strong>({<strong>handler</strong>:handlerFunc})},[handlerFunc]) </pre><pre>  return(<br>     &lt;View&gt;<br>        &lt;TextInput value={name} onChangeText  {(name)=&gt;setName(name)}/&gt; <br>    &lt;/View&gt;</pre><p>In order to get the parameter from the component part use <strong>getParam()</strong></p><pre>foo.navigationOptions=navigationData=&gt;{</pre><pre>const <strong>handler</strong>=navData.navigation.<strong>getParam</strong>(“<strong>handler</strong>”);</pre><pre>return {</pre><pre>   headerRight:(&lt;HeaderButtons <br>       HeaderButtonComponent= {YourHeaderButtonComponent}&gt;<br>       &lt;Item<br>          title=”save&quot;<br>          onPress={<strong>handler</strong>} <br>       /&gt;<br>   &lt;/HeaderButtons&gt;)}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb95766ca89a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native - Navigation]]></title>
            <link>https://mervedilek.medium.com/react-native-navigation-53b567874dc1?source=rss-3351ae40098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/53b567874dc1</guid>
            <dc:creator><![CDATA[Merve Dilek]]></dc:creator>
            <pubDate>Thu, 10 Sep 2020 05:48:06 GMT</pubDate>
            <atom:updated>2020-10-21T11:03:12.058Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*rDQZHMuvWH45Qpi_D2tQAA.png" /></figure><p>For many of complex react native applications that consist of multiple screens, navigation is indispensable. Firstly be sure to install the essential libraries for navigation. For each react navigators you should install separate react navigation libraries.</p><h4>Stack Navigator</h4><p>Before starting to use stack navigator following installation commands should be run</p><p>npm install @react-navigation/stack</p><p>expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view</p><p>In a stack navigator, new screen is placed on top. It gives an opportunity to go back to previous screen and navigate between screens with its additional properties provided by stack navigation.</p><p>After installing steps, a separate navigation folder under the project directory makes it easier to maintain the clarity of logic. In the navigation js file import stack navigation with following lines:</p><pre>import {createStackNavigator} from &quot;react-navigation-stack&quot;;</pre><p>In addition, screens that will be contained in the stack navigator should be imported. Simple example can be given as follows:</p><pre>import Screen1FileName from &quot;../screens/Scree1FileName&quot;<br>import Screen2FileName from &quot;../screens/Scree2FileName&quot;</pre><pre>const stackNav=createStackNavigator(<br>    { <br>        Screen1key: {<br>            screen: Screen1FileName,<br>         navigationOptions:{<br>               headerTitle:&quot;Screen1!&quot;<br>            }<br>        },<br>        Screen2key: Screen2FileName<br>    },<br>)</pre><pre>export default createAppContainer(stackNav);</pre><p><strong>Drawer Navigator</strong></p><p>Ensure that you install drawer navigation with following command:</p><p>npm install @react-navigation/drawer</p><p>In the example below two screens of drawer navigator are shown. These screens are hold in stack navigators, and these stack navigators are wrapped in a drawer navigator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*9dXN5NpNj13HHE-GEDerMw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5fda18945f50c72c2e0fbea301bda0c/href">https://medium.com/media/c5fda18945f50c72c2e0fbea301bda0c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b816f84dd584bc8950dac2dd7c41b00e/href">https://medium.com/media/b816f84dd584bc8950dac2dd7c41b00e/href</a></iframe><p>ScreenB is also implemented in the same way with ScreenA.</p><p>Example above can be downloaded from the following link:</p><p><a href="https://github.com/sagmer/Examples_Navigation">https://github.com/sagmer/Examples_Navigation</a></p><p><strong>Tab Navigator</strong></p><p>Navigators can be used inside other navigators. For instance a tab navigator may contain a stack navigator, which contains another stack navigator etc. In the example below, we used 2 screens inside a tab navigator, which have icons add and appstore. Depending on the platform we used createMaterialBottomTabNavigator (android) and createBottomTabNavigator (ios).</p><p>npm install @react-navigation/bottom-tabs</p><pre>import {createBottomTabNavigator} from &quot;react-navigation-tabs&quot;;<br>import {createMaterialBottomTabNavigator } from &quot;react-navigation-material-bottom-tabs&quot;;<br>import Screen1fileName from &quot;../Screens/Screen1&quot;;<br>import Screen2fileName from &quot;../Screens/Screen2&quot;;<br>import {Ionicons} from &quot;@expo/vector-icons&quot;;<br>import React from &quot;react&quot;;<br>import {Platform, Text} from &quot;react-native&quot;;</pre><pre>const tabScreens={<br>    Screen1: {<br>        screen: Screen1fileName,<br>        navigationOptions:{<br>            tabBarIcon:(tabProps)=&gt;<br>            {<br>                return &lt;Ionicons name=&quot;ios-add&quot; size={25} color={tabInfo.tintColor}/&gt;<br>            },<br>            tabBarColor:COLORS.primaryColor,<br>        }<br>    },<br>    Screen2: {<br>        screen: Screen2fileName,<br>        navigationOptions:{<br>            tabBarIcon:(tabProps)=&gt;<br>            {<br>                return &lt;Ionicons name=&quot;ios-appstore&quot; size={25} color={tabInfo.tintColor}/&gt; <br>            },<br>            tabBarColor:COLORS.accentColor,<br>    }<br>};</pre><pre>const tabNavigator= Platform.OS===&quot;android&quot; <br>? createMaterialBottomTabNavigator(<br>    tabScreens,<br>    {<br>        activeTintColor:&quot;#ffdddd&quot;,<br>    }<br>)<br><br>: createBottomTabNavigator<br>(<br>    tabScreens,<br>    {<br>        tabBarOptions:{<br>            activeTintColor:&quot;black&quot;,<br>        }<br>    }<br>)</pre><p><strong>Switch Navigator</strong></p><p>Switch Navigator does not allow going back to the previous screen and the routes are reset to their default state when they are left. Switch navigators are used commonly for authentication purposes.</p><pre>import {createSwitchNavigator} from &quot;react-navigation&quot;;<br>import Screen1 from &quot;../Screens/Screen1&quot;;<br>import Screen2 from &quot;../Screens/Screen1&quot;;</pre><p>Switch navigator can be created as follows:</p><pre>const MainNavigator = createSwitchNavigator({<br>   Screen1: Screen1StackNavigator,<br>   Screen2: Screen2StackNavigator<br>})</pre><pre>const Screen1StackNavigator= createStackNavigator (<br>{<br>  Scr1 : Screen1<br>}<br>)<br>const Screen1StackNavigator= createStackNavigator (<br>{<br>  Scr2 : Screen2<br>}<br>)</pre><p><strong>Navigation Options</strong></p><p>Screen presentations can be configured with Navigation Options, which can be edited with different ways. One way of setting navigation options is defining it in a functional component file.</p><p><em>Default Navigation Options</em></p><p>Default navigation options of a navigator apply to its child routes if they are not overridden in their screen components.</p><p>If both default navigation options and navigation options are defined in the body of a parent navigator, while default navigation options apply to the children, navigation options are applied to navigator if the navigator will be used in another navigator.</p><p>If navigation options are defined in components or in the screens part of the wrapped components, these options override default navigation options.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53b567874dc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Steps to run your first project]]></title>
            <link>https://mervedilek.medium.com/steps-to-run-your-first-project-c481f239cc42?source=rss-3351ae40098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c481f239cc42</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[install-react-native]]></category>
            <dc:creator><![CDATA[Merve Dilek]]></dc:creator>
            <pubDate>Wed, 09 Sep 2020 13:16:37 GMT</pubDate>
            <atom:updated>2020-09-23T17:52:48.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>Steps to Run Your First React Native Project</h3><p>First step is to install the latest version of Node.js. Since Expo-CLI makes it easy to implement a mobile application with react native many react native projects use Expo.</p><p>You can install expo with the following command line:</p><blockquote>sudo npm install expo-cli — global</blockquote><p>After installation completed, in terminal, you can go to the place where your project will be located in.</p><p>Following command can be used to create an initial project:</p><blockquote>expo init project_name</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1_Wgw3p8BHmcd7hC_lMAw.png" /></figure><p>You can choose blank template and press enter. This will take some minutes.</p><p>After the project is created you can change directory to the newly created project and start the local server of Expo cli by “expo start” command.</p><p>This will open the project on your default web browser.</p><p>If you will work on emulator and simulator you will need to install xcode and Android Studio for ios and android operating systems.</p><p>If you want to see the output directly on your phone, you should install expo and read the barcode from your camera.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0SCclyAKOUajq3I7xvVIQ.png" /></figure><p>Visual Studio Code is a great IDE for react native. From the VSCode terminal, <em>expo start</em> or <em>npm start </em>command will also do the same.</p><p>In order to run your first project on ios simulator you should type “i”, for android emulator your should type “a” after your project is loaded on your browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yVa9bxbH7dw8uhbdeeRrLQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c481f239cc42" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Functional Component Example]]></title>
            <link>https://mervedilek.medium.com/introduction-to-react-native-492cf6cd6e36?source=rss-3351ae40098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/492cf6cd6e36</guid>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[hello-world]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[functional-component]]></category>
            <dc:creator><![CDATA[Merve Dilek]]></dc:creator>
            <pubDate>Sat, 05 Sep 2020 08:00:23 GMT</pubDate>
            <atom:updated>2020-09-24T13:46:40.237Z</atom:updated>
            <content:encoded><![CDATA[<h3>Simple “Hello World” Example by React Native</h3><p>Since functional components are simpler in terms of syntax, reading and testing, they are commonly preferred. Although they have some advantages over class components, they had been called stateless until the usage of Hooks with React. After React v.16.8 versions, with useState Hooks, functional components can be stateful while maintaining their benefits such as simplicity in writing and testing, more focusing on the separation of container and presentation.</p><p>A simple functional component can be given as an example as follows:</p><pre>import React from ‘react’;</pre><pre>import {StyleSheet, Text, View} from ‘react-native’;</pre><pre>const HelloWorld = () =&gt; {</pre><pre>   return (</pre><pre>      &lt;View style={styles.container}&gt;</pre><pre>         &lt;Text style={styles.text}&gt; Hello world!&lt;/Text&gt;</pre><pre>      &lt;/View&gt;</pre><pre>   )</pre><pre>}</pre><pre>const styles = StyleSheet.create({</pre><pre>container: {</pre><pre>   flex: 1,</pre><pre>   backgroundColor: ‘#ddd’,</pre><pre>   alignItems: ‘center’,</pre><pre>   justifyContent: ‘center’,</pre><pre>},</pre><pre>text:{</pre><pre>   fontSize:20,</pre><pre>   color:”red”</pre><pre>}</pre><pre>});</pre><pre>export default HelloWorld;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*01t7lkt9y6-aU0j3EuRbrw.png" /></figure><p>In the example above, text is wrapped by &lt;View&gt;&lt;/View&gt; core component which has simple style properties that center the text on the screen. This is just the easy way to demonstrate a simple “Hello world” text.</p><p>This HelloWorld component is used in our App.js file as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63c_iU09XM8p-xwownRzQQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=492cf6cd6e36" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>