<?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 Navdeep Singh Bedi on Medium]]></title>
        <description><![CDATA[Stories by Navdeep Singh Bedi on Medium]]></description>
        <link>https://medium.com/@navdeepsinghbedi?source=rss-be24cc286415------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZNMAUmmUbGBuA7cHWmhiZw.jpeg</url>
            <title>Stories by Navdeep Singh Bedi on Medium</title>
            <link>https://medium.com/@navdeepsinghbedi?source=rss-be24cc286415------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 09:39:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@navdeepsinghbedi/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[How to Manage Multiple Git Accounts (GitHub and Bitbucket) on a Single Machine]]></title>
            <link>https://medium.com/@navdeepsinghbedi/how-to-manage-multiple-git-accounts-github-and-bitbucket-on-a-single-machine-928678f98de2?source=rss-be24cc286415------2</link>
            <guid isPermaLink="false">https://medium.com/p/928678f98de2</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[bitbucket]]></category>
            <category><![CDATA[version-control]]></category>
            <dc:creator><![CDATA[Navdeep Singh Bedi]]></dc:creator>
            <pubDate>Tue, 17 Sep 2024 02:24:09 GMT</pubDate>
            <atom:updated>2024-09-17T02:24:09.915Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hRi4NL-6U-tzHHRBoCaLDQ.jpeg" /></figure><p>If you’re working with multiple Git accounts — say, one for GitHub and another for Bitbucket — you might run into issues when trying to push code to different repositories, especially if each account has its own SSH keys or credentials. In this guide, I’ll walk you through setting up two Git accounts on the same system, ensuring you can seamlessly work with both accounts.</p><p><strong>Why You Might Need Multiple Git Accounts</strong><br>Developers often juggle different Git accounts for work, personal projects, and open-source contributions. You might:<br>- Use <strong>GitHub</strong> for personal projects and <strong>Bitbucket</strong> for work.<br>- Contribute to different organizations with distinct Git setups.<br> <br>Without the correct configuration, Git will default to the credentials used last, causing authentication conflicts. Let’s resolve that by setting up SSH keys and Git configurations.</p><p>— -</p><h3>Step-by-Step Setup</h3><h4>1. Generate Separate SSH Keys</h4><p>The first step is to create SSH keys for each account, as Git uses these keys to authenticate your identity with remote servers like GitHub and Bitbucket.</p><p><strong>For GitHub:</strong><br>1. Open your terminal and run:</p><pre>ssh-keygen -t rsa -b 4096 -C &quot;your_github_email@example.com&quot;</pre><p>2. You’ll be prompted to save the key. Save it as:</p><pre>/home/your_username/.ssh/id_rsa_github</pre><p>3. When asked for a passphrase, either add one or press Enter to skip.</p><p><strong>For Bitbucket:</strong><br>1. Run the same command for your Bitbucket account:</p><pre>ssh-keygen -t rsa -b 4096 -C &quot;your_bitbucket_email@example.com&quot;</pre><p>2. Save this key as:</p><pre>/home/your_username/.ssh/id_rsa_bitbucket</pre><p>Now, you’ve created two separate SSH keys, one for GitHub and one for Bitbucket.</p><h4><strong>2. Add the SSH Keys to Your SSH Agent</strong></h4><p>Next, you need to add the newly created SSH keys to the SSH agent, so Git knows which key to use for each platform.</p><p>1. Start the SSH agent:</p><pre>eval &quot;$(ssh-agent -s)&quot;</pre><p>2. Add the GitHub key:</p><pre>ssh-add ~/.ssh/id_rsa_github</pre><p>3. Add the Bitbucket key:</p><pre>ssh-add ~/.ssh/id_rsa_bitbucket</pre><h4><strong>3. Configure the SSH Config File</strong></h4><p>Now, we’ll tell Git to use the correct SSH key depending on whether you’re interacting with GitHub or Bitbucket.</p><p>1. Open (or create) your SSH config file:</p><pre>nano ~/.ssh/config</pre><p>2. Add the following lines to configure both accounts:</p><pre># GitHub account<br> Host github.com<br> HostName github.com<br> User git<br> IdentityFile ~/.ssh/id_rsa_github<br># Bitbucket account<br> Host bitbucket.org<br> HostName bitbucket.org<br> User git<br> IdentityFile ~/.ssh/id_rsa_bitbucket</pre><h4><strong>4. Add SSH Keys to GitHub and Bitbucket</strong></h4><p>Next, you need to upload the respective SSH public keys to GitHub and Bitbucket.</p><p><strong>For GitHub:</strong><br>1. Copy the public key:</p><pre>cat ~/.ssh/id_rsa_github.pub</pre><p>2. Go to your <a href="https://github.com/settings/keys">GitHub SSH settings</a> and click <strong>New SSH Key</strong>.<br>3. Paste the copied key and save.</p><p><strong>For Bitbucket:</strong><br>1. Copy the public key:</p><pre>cat ~/.ssh/id_rsa_bitbucket.pub</pre><p>2. Go to your <a href="https://bitbucket.org/account/settings/ssh-keys/">Bitbucket SSH settings</a> and click <strong>Add Key</strong>.<br>3. Paste the copied key and save.</p><h4>5. Configure Git to Use the Correct Account</h4><p>Now, let’s configure Git to use the correct email and name for commits based on the repository you’re working on.</p><p><strong>For Your GitHub Repositories:</strong><br>1. Go to the GitHub repository on your local machine.<br>2. Configure Git for that repository:</p><pre>git config user.email &quot;your_github_email@example.com&quot;<br>git config user.name &quot;Your GitHub Name&quot;</pre><p><strong>For Your Bitbucket Repositories:</strong><br>1. Go to your Bitbucket repository.<br>2. Configure Git for that repository:</p><pre>git config user.email &quot;your_bitbucket_email@example.com&quot;<br>git config user.name &quot;Your Bitbucket Name&quot;</pre><h4>6. Clone Repositories Using the Correct SSH</h4><p>When cloning repositories, you must ensure that Git uses the correct SSH host alias. Since we configured SSH in step 3, Git will now automatically pick the correct SSH key when pushing to either GitHub or Bitbucket.</p><p><strong>Cloning from GitHub:</strong><br>Use the standard GitHub URL:</p><pre>git clone git@github.com:username/repository.git</pre><p><strong>Cloning from Bitbucket:</strong><br>Use the Bitbucket URL:</p><pre>git clone git@bitbucket.org:username/repository.git</pre><h4>7. Handling Multiple Accounts in the Same Git Platform</h4><p>If you have multiple accounts within the same Git platform (e.g., two GitHub accounts), you’ll need to create a separate SSH key and alias each account.</p><p>1. Create another SSH key for your second GitHub account:</p><pre>ssh-keygen -t rsa -b 4096 -C &quot;your_second_github_email@example.com&quot;</pre><p>Save it as:</p><pre>/home/your_username/.ssh/id_rsa_github_work</pre><p>2. Add the following to your `~/.ssh/config` file:</p><pre># Work GitHub account<br> Host github-work<br> HostName github.com<br> User git<br> IdentityFile ~/.ssh/id_rsa_github_work</pre><p>3. When cloning repositories for this account, use the alias:</p><pre>git clone git@github-work:username/repository.git</pre><h4>8. Optional: Using Git Credential Manager for HTTPS</h4><p>If you prefer using HTTPS instead of SSH, or in cases where SSH isn’t allowed, you can use the Git Credential Manager to store credentials for both accounts.</p><p>Install Git Credential Manager:</p><pre>git config - global credential.helper manager-core</pre><p>Then, when prompted, enter the credentials for the respective Git platform. Git will remember them securely.</p><p>— -</p><h4><strong>Conclusion</strong></h4><p>Managing multiple Git accounts on a single machine can be straightforward once you set up SSH keys and configure Git appropriately.</p><p>Now, go ahead and push your code like a pro! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=928678f98de2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Going Restful with Go]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@navdeepsinghbedi/going-restful-with-go-bac886134488?source=rss-be24cc286415------2"><img src="https://cdn-images-1.medium.com/max/1100/1*0Ix04WIItJYxOpL2KcmZDg.png" width="1100"></a></p><p class="medium-feed-snippet">Creating a RESTful API with Go can be a rewarding experience, given Go&#x2019;s simplicity and performance. In this article, we&#x2019;ll take you&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@navdeepsinghbedi/going-restful-with-go-bac886134488?source=rss-be24cc286415------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@navdeepsinghbedi/going-restful-with-go-bac886134488?source=rss-be24cc286415------2</link>
            <guid isPermaLink="false">https://medium.com/p/bac886134488</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[restful-api]]></category>
            <dc:creator><![CDATA[Navdeep Singh Bedi]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 22:21:10 GMT</pubDate>
            <atom:updated>2024-01-11T22:21:37.443Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Build Rest API with Django and PostgreSQL Part 2]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@navdeepsinghbedi/build-rest-api-with-django-and-postgresql-part-2-9de65c7f1f72?source=rss-be24cc286415------2"><img src="https://cdn-images-1.medium.com/max/800/1*QKp5XEbjvA0Svp315N57Rg.jpeg" width="800"></a></p><p class="medium-feed-snippet">This part takes you through setting up django web framework with PostgreSql. Lets start!!</p><p class="medium-feed-link"><a href="https://medium.com/@navdeepsinghbedi/build-rest-api-with-django-and-postgresql-part-2-9de65c7f1f72?source=rss-be24cc286415------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@navdeepsinghbedi/build-rest-api-with-django-and-postgresql-part-2-9de65c7f1f72?source=rss-be24cc286415------2</link>
            <guid isPermaLink="false">https://medium.com/p/9de65c7f1f72</guid>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Navdeep Singh Bedi]]></dc:creator>
            <pubDate>Sun, 28 Jun 2020 13:36:13 GMT</pubDate>
            <atom:updated>2020-06-28T13:36:13.575Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Build Rest API with Django and PostgreSQL Part 1]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@navdeepsinghbedi/build-rest-api-with-django-and-postgresql-part-1-1d4191336451?source=rss-be24cc286415------2"><img src="https://cdn-images-1.medium.com/max/800/1*5HS6OhGI5POuvSwrnMtDnQ.png" width="800"></a></p><p class="medium-feed-snippet">We will be building Rest API using Django and PostgreSQL, so brace yourself for some coding.</p><p class="medium-feed-link"><a href="https://medium.com/@navdeepsinghbedi/build-rest-api-with-django-and-postgresql-part-1-1d4191336451?source=rss-be24cc286415------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@navdeepsinghbedi/build-rest-api-with-django-and-postgresql-part-1-1d4191336451?source=rss-be24cc286415------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d4191336451</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Navdeep Singh Bedi]]></dc:creator>
            <pubDate>Sun, 28 Jun 2020 09:46:20 GMT</pubDate>
            <atom:updated>2020-09-23T14:26:30.328Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Setting up MS SQL Server on Docker and IntelliJ]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@navdeepsinghbedi/setting-up-ms-sql-server-on-docker-and-intellij-2c0a803e41c1?source=rss-be24cc286415------2"><img src="https://cdn-images-1.medium.com/max/668/1*dxhyOInTIvhDjJrTMIYfGw.png" width="668"></a></p><p class="medium-feed-snippet">This article demonstrate a straight forward approach to setup Microsoft SQL Server on a Mac system with the use of Docker and further&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@navdeepsinghbedi/setting-up-ms-sql-server-on-docker-and-intellij-2c0a803e41c1?source=rss-be24cc286415------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@navdeepsinghbedi/setting-up-ms-sql-server-on-docker-and-intellij-2c0a803e41c1?source=rss-be24cc286415------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c0a803e41c1</guid>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[mssql-server]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[intellij]]></category>
            <dc:creator><![CDATA[Navdeep Singh Bedi]]></dc:creator>
            <pubDate>Thu, 25 Apr 2019 06:23:40 GMT</pubDate>
            <atom:updated>2019-04-25T07:10:48.256Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Handling Network APIs in React-Native : My Approach]]></title>
            <link>https://medium.com/front-end-weekly/handling-network-apis-in-react-native-my-approach-e1e5f138fa6e?source=rss-be24cc286415------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1e5f138fa6e</guid>
            <category><![CDATA[axios]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Navdeep Singh Bedi]]></dc:creator>
            <pubDate>Wed, 31 Jan 2018 06:14:35 GMT</pubDate>
            <atom:updated>2018-02-02T09:20:58.569Z</atom:updated>
            <content:encoded><![CDATA[<p>With the advent of React-Native new possibilities are thriving in Mobile App market. Javascript developers are headed to launch their new Apps built using React-Native. So here I would explain my approach for a very important task in App Development i.e. <strong>Handling Network APIs .</strong></p><h3><strong>React-Native Docs Approach — Using Fetch :</strong></h3><p>React Native provides the Fetch APIs for handling networking . Fetch is similar to XMLHttpRequest or other networking APIs before.</p><p><strong>Making Request<br></strong>In order to fetch content from an arbitrary URL, just pass the URL to fetch:</p><pre>fetch(&#39;https://mywebsite.com/mydata.json&#39;);</pre><p>Fetch also takes an optional second argument that allows you to customise the HTTP request. You may want to specify additional headers, or make a POST request:</p><pre>fetch(&#39;https://mywebsite.com/endpoint/&#39;, {<br>   method: &#39;POST&#39;,<br>   headers: {<br>     Accept: &#39;application/json&#39;,<br>     &#39;Content-Type&#39;: &#39;application/json&#39;,<br>   },<br>   body: JSON.stringify({<br>     firstParam: &#39;yourValue&#39;,<br>     secondParam: &#39;yourOtherValue&#39;,<br>   }),<br> });</pre><p>For more : <a href="https://developer.mozilla.org/en-US/docs/Web/API/Request">Fetch Request docs</a>.</p><h3><strong>My Approach :</strong></h3><p>At first I started using <a href="https://www.npmjs.com/package/react-native-axios">Axios</a>, a promise based HTTP client for browser and node.js . Its usage is similar to Fetch but with a promise, like this:</p><pre>axios.get(&#39;/user?ID=12345&#39;)<br>.then(function (response) {<br>  console.log(response);<br>})<br>.catch(function (error) {<br>  console.log(error);<br>});</pre><p>But with complexity in App I created a central file for all the handling of networking. It would also be easy to handle response codes and other errors at a same place rather then in each Component. So I created a file called ApiCentral.js .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8997683087499ad606b48f110ee5af9c/href">https://medium.com/media/8997683087499ad606b48f110ee5af9c/href</a></iframe><p>The request function takes <strong>options</strong> and <strong>isHeader</strong> as arguments :<br><strong>options : </strong>Axios client options as an object.<br><strong>isHeader : </strong>boolean to check whether to add headers or not.</p><p>Now we could create a Service for calling the request like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da30288de327610cf5418e256c872440/href">https://medium.com/media/da30288de327610cf5418e256c872440/href</a></iframe><p>And for further usage in your Actions or Components we would use these services like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6de2a053249369bb0c33c32ca460beb8/href">https://medium.com/media/6de2a053249369bb0c33c32ca460beb8/href</a></iframe><p>These services could be used module wise to reduce clutter in code and easy to read or debug the code.</p><p>This was my way to resolve the complexity of my code and make it reusable. As I am new to React-Native I am open for your feedback. Please share your views about this approach.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1e5f138fa6e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/handling-network-apis-in-react-native-my-approach-e1e5f138fa6e">Handling Network APIs in React-Native : My Approach</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React-Native: Setting up project structure.]]></title>
            <link>https://medium.com/react-native-coach/react-native-setting-up-project-structure-84f08f0d17aa?source=rss-be24cc286415------2</link>
            <guid isPermaLink="false">https://medium.com/p/84f08f0d17aa</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Navdeep Singh Bedi]]></dc:creator>
            <pubDate>Mon, 08 Jan 2018 05:39:08 GMT</pubDate>
            <atom:updated>2018-01-10T01:09:17.130Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rPFMa_L1RG8ezpfd43pC6A.jpeg" /></figure><p>React-Native gives a great deal of flexibility : You could try out anything and setup your project structure as you please. After initial setup the default structure provides a base for new developers , however for complex projects you have to take a approach which does not hinder the development pace in future.</p><h4><strong>Understanding default structure :</strong></h4><p>Here we understand the basic files and folders of the default project :</p><ul><li><strong>./android : </strong>This directory contains the Android native project with all source in .java, .xml and .gradle files. This project could be opened in Android Studio to make tweaks or add libraries as you go along.</li><li><strong>./ios : </strong>Similar to last directory this directory contains iOS native project , which could be opened in Xcode and work on its native part.</li><li><strong>./node_modules: </strong>This directory contains all the npm packages installed in your project. You don’t have to worry to handle this directory .</li><li><strong>index files (index.ios.js and index.android.js): </strong>This is the entry point for your app into the React Native code. It’s where you’ll want to register your app (via <em>AppRegistry</em>). The middle name <strong>ios /android </strong>suggest which platform these file would work on.</li></ul><h4><strong>Setting up Files Structure for small projects:</strong></h4><p>First basic step is to setup <strong>./App </strong>directory, this would contain all the source code of the React-Native app. First let me show how this would look:</p><pre>-App <br> --constants<br> --screens<br> --components<br> --actions<br> --reducers<br> --store<br> --utils</pre><p><strong>./constants: </strong>This directory could contains all the constants files. These files could contain Base URL for APIs , API keys etc. This could also contains Action types.</p><p><strong>./screens : </strong>This directory would contains all the files with screens i.e. the routes/scenes.</p><p><strong>./components : </strong>This directory contains all the basic components which projects need . It could be further divided into directory for each component with its<strong> own style.js </strong>file.</p><p><strong>./actions and ./reducers : </strong>React-Native apps have extensive use of Redux . So to setup Redux we could use these two directories for actions and reducer files.</p><p><strong>./store: </strong>This contains the configuration for middleware store.</p><p><strong>./utils: </strong>This directory would contains any files with utility functions.</p><p>But in my own view this structure could only be used in small projects . Further I would show you structure for more complex project.</p><h4><strong>Structure for more Complex projects:</strong></h4><p>The problem with last structure is the project structure is divided by the functional criteria instead of Project business modules. So here is new approach:</p><pre>-App<br> --constants<br> --modules<br> --network<br> --reducers<br> --store<br> --utils</pre><p>You will notice some directories are similar to last structure.</p><p><strong>./reducers </strong>will contain common reducers files (For e.g. setting initial state of App).</p><p><strong>./network </strong>contains files to create functions for API interaction . For e.g:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18d9f5a7afbc23f884c94f15318e5860/href">https://medium.com/media/18d9f5a7afbc23f884c94f15318e5860/href</a></iframe><p>But most important is modules directory which could be further divided as:</p><pre>-modules<br> --common<br> --example_module<br>  --components<br>  --example.actions.js<br>  --example.reducers.js<br>  --example.js</pre><p>Now this could be confusing at first but this would be beneficial further.</p><p><strong>./common: </strong>This directory would contain common components for whole project.</p><p><strong>./example_module: </strong>This is an example of a module directory . This is further divided into <strong>./components </strong>which contain components specific to this module, <strong>example.actions.js and example.reducer.js </strong>these files are used for Redux implementation in this module and <strong>example.js </strong>is the module screen.</p><p>Further I would say this is what I found best and my personal approach. I am open for suggestion as I am new to React-Native .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84f08f0d17aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-coach/react-native-setting-up-project-structure-84f08f0d17aa">React-Native: Setting up project structure.</a> was originally published in <a href="https://medium.com/react-native-coach">React Native Coach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Flexbox in React Native]]></title>
            <link>https://medium.com/react-native-coach/understanding-flex-in-react-native-b34dfb4b16d1?source=rss-be24cc286415------2</link>
            <guid isPermaLink="false">https://medium.com/p/b34dfb4b16d1</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Navdeep Singh Bedi]]></dc:creator>
            <pubDate>Wed, 03 Jan 2018 09:57:22 GMT</pubDate>
            <atom:updated>2019-03-13T04:08:46.004Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*duHjEv7_AnJj4UtB6gV2_Q.jpeg" /><figcaption>The struggle is real</figcaption></figure><h4>Mastering these simple Flexbox recipes will make you a React Native UI master in no time</h4><h4>Getting Started</h4><p>Lets start with a simple example. A container View component with three Text components.</p><pre>//Our views</pre><pre>&lt;View style={styles.container}&gt;<br>  &lt;View style={styles.viewStyleOne}&gt;<br>    &lt;Text style={styles.textStyle}&gt; 1 &lt;/Text&gt;<br>  &lt;/View&gt;</pre><pre>  &lt;View style={styles.viewStyleTwo}&gt;<br>    &lt;Text style={styles.textStyle}&gt; 2 &lt;/Text&gt;<br>  &lt;/View&gt;</pre><pre>  &lt;View style={styles.viewStyleThree}&gt;<br>    &lt;Text style={styles.textStyle}&gt; 3 &lt;/Text&gt;<br>  &lt;/View&gt;</pre><pre>&lt;/View&gt;</pre><pre>//Styles</pre><pre>let styles = StyleSheet.create({<br>  container: { backgroundColor:&#39;#4286f4&#39;},<br>  viewStyleOne: {<br>    width:40,<br>    height:40,<br>    justifyContent: &#39;center&#39;,<br>    alignItems:&#39;center&#39;, <br>    backgroundColor:&#39;#b642f4&#39;<br>  },<br>  textStyle:{<br>    textAlign:&#39;center&#39;<br>  }<br>})</pre><p>Which renders as so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*3HQ4OzzQ_f7YC08e4MC1aA.png" /><figcaption>Initial View</figcaption></figure><h3><strong>Styling the Container</strong></h3><p>Now we add <strong>flex:1 </strong>to the container:</p><pre>container: { <br>  backgroundColor:&#39;#4286f4&#39;, <br>  flex: 1 <br>}</pre><p>This makes container fill its parent, i.e. whole screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*paexc9cORnfjUdBrFTHxdw.png" /><figcaption>flex : 1</figcaption></figure><p>Now we add:</p><pre>container: { <br>  backgroundColor:&#39;#4286f4&#39;, <br>  flex: 1,<br>  flexDirection:&#39;row&#39;<br>}</pre><p>Each view’s flexDirection<strong> </strong>is set to colum by default but setting it to ‘row’ will change the orientation of the items in the container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*j9wCE8KD5-bPfzWPV6-XXQ.png" /><figcaption>flexDirection set to ‘row’</figcaption></figure><p>Now we can control the orientation of the content using flexDirection.<br>Now lets add justifyContent and alignItems :</p><pre>container:{ <br>  backgroundColor:&#39;#4286f4&#39;, <br>  flex: 1, <br>  flexDirection: &#39;row&#39;,<br>  justifyContent: &#39;flex-end&#39;,<br>  alignItems:&#39;flex-start&#39;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*8RIz80L9ODeeXqAMiblgBQ.png" /><figcaption>justifyContent: ‘flex-end’</figcaption></figure><p>Similarly for:</p><pre>container: { <br>  backgroundColor:&#39;#4286f4&#39;, <br>  flex: 1, <br>  flexDirection: &#39;row&#39;,<br>  justifyContent: &#39;flex-end&#39;,<br>  alignItems:&#39;flex-end&#39;<br>}</pre><p>Views will render like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*HDLVxWi68iLG11wPIRu0qQ.png" /><figcaption>alignItems:’flex-end’</figcaption></figure><ul><li>flexDirection determines the primary axis as ‘<strong>row</strong>’ or ‘<strong>column</strong>’.</li><li>justifyContent determines distribution of children along <strong>primary axis</strong>.</li><li>alignItems<strong> </strong>determines the <strong>alignment</strong> of children along the <strong>secondary axis.</strong></li></ul><p>To set items to center :</p><pre>justifyContent: &#39;center&#39;,<br>alignItems:&#39;center&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*BuTPu8_XSKf304jX4bxYuw.png" /><figcaption>Items to center</figcaption></figure><p>justifyContent supports flex-start, center, flex-end, space-around, and space-between.</p><p>For space-around:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*frg588MPDuv8Q-ley6Lu0A.png" /><figcaption>space-around</figcaption></figure><p>and space-between:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*fdetrzgAcHBKItbkbRd_PA.png" /><figcaption>space-between</figcaption></figure><p>alignItems supports: flex-start, center, flex-end, and stretch.</p><h3><strong>Overriding the Container Style</strong></h3><p>If we need an item to override<strong> </strong>it’s defined as defined by the container we could use style the items individually.</p><p>alignSelf overrides alignItems and supports these options auto, flex-start, flex-end, center, stretch and baseline.</p><p>If we tell an item to align itself to flex-start,</p><pre>alignSelf: &#39;flex-start&#39; </pre><p>It would end up like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*4vaQyDO1IiD5wv80aYXMgQ.png" /><figcaption>telling the item to align at flex start</figcaption></figure><p>flexGrow<strong> </strong>controls how much the item will grow relative to the rest of the flexible items inside the same container.</p><pre>flexGrow: 1</pre><p>Would render as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*DAVqu8Kbq4z1khLPYI_EqQ.png" /><figcaption>flexGrow</figcaption></figure><p>flexBasis<strong> </strong>controls the item size with percent. For eg:</p><pre>flexBasis:50 //firstView style<br>flexBasis:20 //secondView style<br>flexBasis:30 //ThirdView style</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*kIISdUL--Zm3q82IkvY_Tw.png" /><figcaption>flexBasis</figcaption></figure><h3>Thanks for Reading!</h3><p>These are the basic use of flex for React View components. I will update as I learn more. Thanks for reading and feel free to leave questions in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b34dfb4b16d1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-native-coach/understanding-flex-in-react-native-b34dfb4b16d1">Understanding Flexbox in React Native</a> was originally published in <a href="https://medium.com/react-native-coach">React Native Coach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>