<?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 Kashish Grover on Medium]]></title>
        <description><![CDATA[Stories by Kashish Grover on Medium]]></description>
        <link>https://medium.com/@kashishgrover?source=rss-9cb8c42f6dc8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Co3Mv5VaRBkarAojA5jcpg.jpeg</url>
            <title>Stories by Kashish Grover on Medium</title>
            <link>https://medium.com/@kashishgrover?source=rss-9cb8c42f6dc8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:37:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kashishgrover/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[Our React Native App Looks Much Better Now]]></title>
            <link>https://tech.treebo.com/our-react-native-app-looks-much-better-now-3a18fe223662?source=rss-9cb8c42f6dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a18fe223662</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Kashish Grover]]></dc:creator>
            <pubDate>Fri, 30 Nov 2018 22:33:14 GMT</pubDate>
            <atom:updated>2018-12-01T11:00:01.268Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4k8157JP5jnvozmsEwh2yQ.jpeg" /></figure><p>Hello there! I haven’t written in a while. Mainly because I have been busy doing a lot of new and cool things at Treebo.</p><p>Recently we implemented something really interested in our React Native app at Treebo. We decided to fix how our app looks across all sorts of devices. When I first started with React Native about a year ago, I used to think that this is something that React Native will handle automatically for me. I was quick to realise that I was wrong there because my work would look really different on different phones.</p><p><strong>I compared how our app looked on the iPhone 5, the iPhone 8, the iPhone X, my OnePlus 3T, a OnePlus 6, the first generation Moto X, and even a Redmi 2.</strong> The difference was shocking and there was always this itch in my brain to fix this for good.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F60rOQZzt2xdu6oxMtA%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F60rOQZzt2xdu6oxMtA%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F60rOQZzt2xdu6oxMtA%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="295" frameborder="0" scrolling="no"><a href="https://medium.com/media/347558393e658e0cfd408979d82296d2/href">https://medium.com/media/347558393e658e0cfd408979d82296d2/href</a></iframe><p>Between business decisions and features this was never prioritised early on. We knew we had to fix this whenever we got the chance and finally we did somewhere around September. Our design team said that they really disliked how small the fonts look on some devices. I decided to add some form of a multiplication factor to the font sizes so they looked better. Except the fact that now our paddings, margins, widths and heights looked so weird! <strong>I knew this ‘scaling’ had to be done everywhere.</strong></p><p><a href="https://github.com/treebohotels/leaf-ui"><strong>Luckily for us, we had been working on Treebo’s design system — Leaf UI</strong></a>. Over this exercise, we improved upon LeafUI’s React Native components a lot. Every component of the app had to be fixed. Because if there was one place where we could control how all our apps look on thousands of Android and a few iOS devices, it was LeafUI.</p><p>Let me tell you in detail about what we did, and we shall also compare how the app used to look before vs how it looks now.</p><h3>What is a design system?</h3><blockquote><a href="https://forumone.com/ideas/what-is-design-system">A design system is a series of components that can be reused in different combinations. Design systems allow you to manage design at scale.</a></blockquote><p>If you open the link above, you’ll see their analogy of comparing it with a pack of LEGO bricks. No wonder someone like <a href="https://twitter.com/baconbrix?lang=en">Evan Bacon</a> works at <a href="https://expo.io/">Expo</a>. 🤔</p><p>With React and React Native taking our industry by storm, having a design system for your applications is more relevant than ever. Today, making new UI’s on our app is the easiest part of my job. And all that is just because we have Leaf UI.</p><p>Now I don’t expect you to start an open source project and make a library. You could very well just have a folder where you have all your base components. Initially these could probably just be exporting things from other libraries or even React Native’s own components. Or just 🌚</p><pre>npm install --save leaf-ui</pre><p>The idea here is to <strong>always have an abstraction layer</strong>. Because that is how you write scalable code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F103TZqgLqRJq0M%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F103TZqgLqRJq0M%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F103TZqgLqRJq0M%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="271" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6d176b1929e14a9742f7394f37d07b0/href">https://medium.com/media/d6d176b1929e14a9742f7394f37d07b0/href</a></iframe><h3><a href="https://github.com/treebohotels/leaf-ui">Leaf UI — The Treebo Way</a> 🍃</h3><p>Leaf UI at its core was a really simple idea. We wanted two things out of it —</p><ol><li>Write once (per platform), and use everywhere.</li><li>Not having to write styles in our projects.</li></ol><p>For that very reason, we have two types of components in LeafUI — Regular Components and Enhancer Components.</p><blockquote><strong>Regular Components</strong> are simple components like Button, Card, Text, Form, TextInput, etc.</blockquote><blockquote><strong>Enhancer Components</strong> are responsible for the positions, paddings, margins, layouts and size. Conveniently there are 4 of them — Flex, Space, Position, and Size.</blockquote><p>We needed it to support both React and React Native. And boy it does that really well! <a href="https://leaf-ui.treebo.com/">You can see the React implementation here.</a></p><p>With LeafUI in place, let’s see how our code looks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d88afa4474a1fff48f84efd472bec7d4/href">https://medium.com/media/d88afa4474a1fff48f84efd472bec7d4/href</a></iframe><p>Easy to read, right? Notice the fact that I wrote no explicit styles here. Space and Flex simply pass down their props to the Card component.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl3q2S3tOqlIJSngdi%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl3q2S3tOqlIJSngdi%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fl3q2S3tOqlIJSngdi%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="224" frameborder="0" scrolling="no"><a href="https://medium.com/media/37916dbc69209fdc8708f923b3723e0c/href">https://medium.com/media/37916dbc69209fdc8708f923b3723e0c/href</a></iframe><h3>The centralised algorithm. Don’t grill me on this. I know it can be better. 😐</h3><p>The algorithm, is rather simple. And we only cater to portrait modes on phones. I am no mathematician and after a lot of trial and error and googling, I reached this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93e38d960299828afb246ca2f8522f5c/href">https://medium.com/media/93e38d960299828afb246ca2f8522f5c/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fa5viI92PAF89q%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fa5viI92PAF89q%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMGhhZWI4ZjcwOGl4andycHJkY211YXVsdWdkbmpqOXZibXk1ZzhvYiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2Fa5viI92PAF89q%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/46a8a563f1ce9e14a0ffa3b5a4662a93/href">https://medium.com/media/46a8a563f1ce9e14a0ffa3b5a4662a93/href</a></iframe><p>I don’t know if this is right or wrong. But it does work really well on every single device that I have come across. And that is not even the point I am trying to make. <strong>The biggest single thing we got out of this exercise is that our whole algorithm is now centralised. Tomorrow if we find something which works better, we’ll have one source of truth to edit.</strong></p><p>And now that you have this, instead of directly putting any numbers in your styles, use scale(number).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/addac152a7813fe88db90cc64fa31082/href">https://medium.com/media/addac152a7813fe88db90cc64fa31082/href</a></iframe><p><strong>Doing this for every single component you make or every single style you write will be really cumbersome.</strong> <strong>That’s why doing it in the design system itself had to be the way.</strong> That way every single padding, margin, fontSize I desire would have gone through it first.</p><p>Let’s look at that banner code again.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32162f5824aa22bcb46327519fd41fe9/href">https://medium.com/media/32162f5824aa22bcb46327519fd41fe9/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl36kU80xPf0ojG0Erg%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl36kU80xPf0ojG0Erg%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fl36kU80xPf0ojG0Erg%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="242" frameborder="0" scrolling="no"><a href="https://medium.com/media/8554bc91b59af91f27bbfcf97f6099ad/href">https://medium.com/media/8554bc91b59af91f27bbfcf97f6099ad/href</a></iframe><p>It’s the same but still so different!</p><h3>You’ve got to see the comparison.</h3><h4>Before…</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8GoBSloSaaePcHh6_z9erA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F3Rev0Lrw4POo9Fa-I2csA.png" /><figcaption>Yeah I see the notch issue. It’s fixed now.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0N3wV_rAxFDDq6xmzfzKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EaVWWGRb2cpHTuYgCgS7NQ.png" /><figcaption>My eyes hurt as well</figcaption></figure><h4>After…</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bNza2URAo6u6sSf8jadyFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KoMMvFwBf8qk9Fx3GDoi5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0zxFwOg2sXHK5XIg6IvL-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d62YLhjA3L-ngz1CVaEOSw.png" /></figure><h4>Side by side comparison…</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9s4fsECeig2Y-0rGQgKwpw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dUnx8hsmSguEvbpYt3lKEA.png" /></figure><p>The difference is too little on some devices and I had a feeling that it might happen. Because those devices probably lie in the sweet spot of what that algorithm can do to them. However, notice the stark difference in the way the app looks on the iPhone X. So many phones after 2016 moved towards the 16:9 aspect ratio. Even if on some devices the difference was small, the aesthetics improved overall.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*iH2I5z9VavRilGKwru0csw.jpeg" /></figure><h3>Wait a minute! Settings &gt; Display &gt; Font Size!</h3><p>Or in iOS, Settings &gt; General &gt; Accessibility &gt; Larger Text</p><p>The above result looks great to me, but I did forget about one crucial thing before going to production — The fact that users can control the text size in their phones. Basically old people broke my design.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*Rw7q79kUTZCcZVU8FnD1qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*l9-Zm0pDuO5dg5VFQXpkxA.png" /><figcaption>Old people broke my design. :(</figcaption></figure><p>That is something that might mess with your design! Just look at that!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F12XMGIWtrHBl5e%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fthe-office-no-steve-carell-12XMGIWtrHBl5e&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExNXZ2OThqOXM4Z2N1Mjd6OTVoaGQ4N2poOHFkOGhpeDFwbmM4eTVkeiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F12XMGIWtrHBl5e%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="357" frameborder="0" scrolling="no"><a href="https://medium.com/media/f93f265f56a13b1ba2ff3aa28c9b098c/href">https://medium.com/media/f93f265f56a13b1ba2ff3aa28c9b098c/href</a></iframe><p>Luckily for us, there is a very simple way to override that behaviour. In the root file of your app, just do this. 😂</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9c5b1df70dcf866f655905bbfcc2507/href">https://medium.com/media/b9c5b1df70dcf866f655905bbfcc2507/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*Rw7q79kUTZCcZVU8FnD1qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*sK2NTVQV1iS8rXEAWC_fAQ.png" /><figcaption>Before and After — allowFontScaling: false</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*l9-Zm0pDuO5dg5VFQXpkxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*zkqUSNRed5fROJ89gj1DYg.png" /><figcaption>Before and After — allowFontScaling: false</figcaption></figure><p>It’s in production now. 😅</p><h3>I still have an itch in my brain</h3><p>I know that the trick I used isn’t the best solution and I’m trying hard to find something better. During this exercise, I tried a bunch of different methods before I implemented the above trick and I wasn’t happy with the result. Still, following are two links you should check out.</p><ul><li><a href="https://github.com/nirsky/react-native-size-matters">https://github.com/nirsky/react-native-size-matters</a>.</li><li><a href="https://medium.com/@shanerudolfworktive/7-tips-to-develop-react-native-uis-for-all-screen-sizes-7ec5271be25c">https://medium.com/@shanerudolfworktive/7-tips-to-develop-react-native-uis-for-all-screen-sizes-7ec5271be25c</a> <br>In this article the author talks about how he used AspectRatio and Percentage to achieve a great result. I’ve still got to try and see how and if it fits our use case.</li></ul><h3>What do you think?</h3><p>I am looking for some constructive criticism here because I know my work is not complete. All this is what I as an engineer could come up with. There must be better ways to do this. If and when I find something better, I’ll simply have to move things around in our design system and update LeafUI in my projects. :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJSUIQgEVDM4%3Fstart%3D58%26feature%3Doembed%26start%3D58&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJSUIQgEVDM4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJSUIQgEVDM4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/be48ff62dd1e9949d4da8d11731b2182/href">https://medium.com/media/be48ff62dd1e9949d4da8d11731b2182/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a18fe223662" width="1" height="1" alt=""><hr><p><a href="https://tech.treebo.com/our-react-native-app-looks-much-better-now-3a18fe223662">Our React Native App Looks Much Better Now</a> was originally published in <a href="https://tech.treebo.com/">Treebo Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bootstrapping your React Native App]]></title>
            <link>https://tech.treebo.com/bootstrapping-your-react-native-app-c859e939e4a2?source=rss-9cb8c42f6dc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c859e939e4a2</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[app-development]]></category>
            <dc:creator><![CDATA[Kashish Grover]]></dc:creator>
            <pubDate>Sat, 21 Apr 2018 06:15:32 GMT</pubDate>
            <atom:updated>2018-05-10T07:59:51.678Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jmmgs9zRg8P6-wCR4YYmxA.png" /></figure><p>Well, hello there. I have been playing around with React Native for a while now and I love it. Not a day goes by where I don’t think about how cool this world of hybrid apps has become. It’s currently on version 0.55.</p><p>Production apps are built around something which is on version 0.55, you ask? Well, yeah. So many companies are using it. Instagram, Myntra, AirBnB, Uber, Facebook, and of course, we at Treebo. But what’s the big deal? Why is there so much hype around it and why am I here today writing to you?</p><p>At Treebo, we believe that React Native is the future of mobile apps and we continue to improve over time, feature by feature, and bugfix by bugfix.</p><h3>Why React Native?</h3><p>The most important thing is that your app will implicitly support iOS and Android through one single codebase. You save time coding, and you save money hiring.</p><p>Not just that, if your ecosystem involves you using React already, you can make sure that most of your apps, whether web or native, look and work the same way.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl0HlxFuQwoTDkwuPe%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0HlxFuQwoTDkwuPe%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0HlxFuQwoTDkwuPe%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b46b08570b7a0a654dd822a4eab8677/href">https://medium.com/media/1b46b08570b7a0a654dd822a4eab8677/href</a></iframe><p>And it’s a myth that you need to know React before you start with React Native. I started with React Native. :)</p><h3>I won’t tell you how to make an app.</h3><p>Well, figure it out. I have been trying to along with so many other people even today. Google it, find out how to do things, visit Stack Overflow, GitHub issues, and even join slack channels with developers who might be able to help you figure out why you are stuck and what you can do. Talk to your peers because half of your problems are JS related anyway.</p><p>So many times you will realise while coding an app in React Native — there might not be a right answer to your problem, yet. But I guess in my opinion, that’s the fun part. How often do you otherwise see issues a couple of weeks old with comments just a couple of hours old for a problem you are trying to solve? You are not alone.</p><p>Meanwhile, amazing developers around the world are building some of the most amazing libraries for you. Take React Navigation for example. A once hated library, it has gained momentum to a point where just a few months ago, it was on 0.something.beta27. As I write this article, <a href="https://reactnavigation.org/blog/2018/05/07/react-navigation-2.0.html">they have released the version 2 </a>with almost everything you may need for your navigation hiccups.</p><p>Isn’t that crazy?</p><h3>I’m here to help you make decisions</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl0MYKzvI7xx5vyhvW%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0MYKzvI7xx5vyhvW%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0MYKzvI7xx5vyhvW%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="299" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6243ea719d2e623bea56a8cc4b2ee6a/href">https://medium.com/media/d6243ea719d2e623bea56a8cc4b2ee6a/href</a></iframe><p>There is so much going around in the React Native world that it is rather hard to keep a track of everything. As someone who is just starting out, you may ask me — where the heck do I begin?</p><p>I would have only one advice — start building, today itself, and get cozy. It gets really easy really soon. You will find yourself going to <a href="https://facebook.github.io/react-native/docs/getting-started.html">Facebook’s React Native docs</a> really often, so bookmark that first thing.</p><h4>Starting up</h4><p><strong>Way 1:</strong> Install <strong>Expo’s XDE</strong> to initialise and run your project — Just visit <a href="https://expo.io/">https://expo.io/</a> and they will help you. Their documentation is one of the best I have read.</p><p>You can also globally install create-react-native-app (CRNA) and do</p><pre>$ create-react-native-app my-app<br>$ cd my-app<br>$ yarn start</pre><p>And that’s it! you can go ahead and now use it with Expo’s Android/iOS app or you can use a simulator on your machine to run your new project on.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FjKaFXbKyZFja0%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FjKaFXbKyZFja0%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FjKaFXbKyZFja0%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="368" frameborder="0" scrolling="no"><a href="https://medium.com/media/9341bbe2aa3e4d88497c48466000b237/href">https://medium.com/media/9341bbe2aa3e4d88497c48466000b237/href</a></iframe><p>Deep into your app development, someday, you may realise that this new feature you want to build doesn’t have any API’s available for in react native yet, and you would like to write your own native code for iOS and Android. That day, you can always choose to eject your project. You can find a full tutorial around it <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md">here</a>. 🙂</p><p><strong>Way 2: The bare-bones</strong></p><p>To keep your dependencies low, you can also initiate your app using the <strong>react-native-cli</strong>.</p><ol><li>Install react-native-cli</li><li>$ react-native init AwesomeProject</li><li>$ cd AwesomeProject</li><li>$ react-native run-ios or $ react-native run-android</li><li>Change code and have fun</li></ol><h4><strong>Android/iOS: Which way to go?</strong></h4><p>When you are just starting out, don’t think about your target platform. Think about your business logic first. But then even if you’re not actively focusing on both platforms, try to build for them together.</p><p>Don’t assume that it’s cross platform and you’ll do iOS first and Android later. Well it is true that it is cross-platform. But there still are a lot of little things like iOS and Android handling margins differently, or Android using elevations instead of box shadows.</p><p>Even though these may be small things, handling them concurrently is the way to go. But at the end of the day, it depends on what devices you have. If you use a linux/windows/android ecosystem and don’t have a Mac or an iPhone, you clearly will build for Android. :P</p><h3>Parts of your app</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8GrTZB9vk0NjKoaZA3S_HA.png" /></figure><h4>Components</h4><p>Start out with React Native’s own components, and use them heavily. You have View, Text, Button, Touchables, ScrollView, KeyboardAvoidingView, WebView, Flatlist — basically all the kinds of components you will ever need for your app. All UI libraries are simply based on these components.</p><p>Just like Bootstrap, Material UI, etc. for web, you will find a few libraries available for React Native too. One of the most popular ones is <a href="https://nativebase.io/">Native Base</a>. We at Treebo are also building a complete library for both React and React Native. We call it <a href="https://github.com/treebohotels/leaf-ui">Leaf UI</a>, and it is our open source gift for the community.</p><p>The whole point of these UI libraries is that they ease your job of applying certain kind of components — like Toast notifications. You might end up spending a lot of time if you try to make them yourself.</p><p>But always remember that no matter what, simplicity is the key. The more the dependencies, the harder it gets to keep a track, and you don’t want to end up in a dependency hell. That’s why a best practice is to <strong>have your own auxiliary components</strong>. For example, create your own Button which internally returns TouchableOpacity from React Native or the Button from Native Base. Tomorrow if you find a better solution, you will just have to change one file.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3VydkbG6UOcUg%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3VydkbG6UOcUg%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3VydkbG6UOcUg%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/3eb363ad2ea3586b6400cf90a37abda8/href">https://medium.com/media/3eb363ad2ea3586b6400cf90a37abda8/href</a></iframe><h4>Handling Images</h4><p>Images might be a big part of your app, and React Native has an <em>Image </em>component which easily renders local and remote images. One thing you should remember is that there is no native support for SVG’s available and that is a very sad thing. :(</p><p>We do have a library called <a href="https://github.com/react-native-community/react-native-svg">react-native-svg</a> available, which lets you write custom SVGs. But this will limit you a lot because you cannot render locally stored or remote SVG’s, and you will have to write them yourself. A not so great alternative to rendering SVG’s is to use WebViews. This would be performance heavy, so you are better off using PNGs or JPEGs here.</p><p>Sad? Well I have found one solution for SVGs which fits my need. It’s <a href="https://github.com/chrisbull/svg-to-react-native-cli">this awesome CLI </a>which I found a while back which converts SVG files to React Native Components which you can use with react-native-svg. I don’t know how scalable this method is, or in how many cases it will work well. But I have used it rather heavily. :)</p><p>For <strong>icons</strong>, a lot of people use fonts. You have a library called react-native-vector-icons which uses fonts. You can use your own fonts too! Check out <a href="https://icomoon.io/">Icomoon</a>.</p><h4>Navigation</h4><p>Navigation is one of the most important aspects of any app. It is also something which isn’t provided to you out of the box in React Native.</p><p>It is extremely important to do this right since the beginning because the whole skeleton of your app will depend on navigation. I highly recommend <a href="https://reactnavigation.org/">React Navigation</a>. I remember how difficult it used to be to use it when it was still in its beta phase. The documentation was super confusing too, maybe it still is for beginners. Since then it has seen a tremendous amount of contributions and as of recent, it is at a release candidate version 2.</p><p>To navigate from one screen to another, you simply pass navigation as a prop between components and do this.props.navigation.navigate(&#39;CoolScreen&#39;);</p><p>Take the following example of the boilerplate that Expo gives you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F1L123In07sC-BSNN0kCSA.png" /></figure><p>Here, you see three screens and a TabBar at the bottom. The TabBar is a navigator which controls these three views. In React Navigation, you can nest your navigators. Also in any navigator, you can mount any number of screens.</p><p>So the code looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TXpLDyjMiJ5vEwulyu7CWw.png" /></figure><p>Here, your TabNavigator is used as a screen in the RootNavigator. You could nest them like this or in any way that suits your logic. :)</p><p>If you think this library is not for you, there are a few other options which are as follows:<br> — <a href="https://github.com/aksonov/react-native-router-flux">React Native Router Flux</a><br> — <a href="https://github.com/wix/react-native-navigation">React Native Navigation</a><br> —<a href="https://github.com/ReactTraining/react-router/"> React Router Native</a></p><h4>State Management</h4><p>There are two types of data that control a component: props and state. props are set by the parent and they are fixed throughout the lifetime of a component. For data that is going to change, we use state.</p><p>Your whole app can be built around component specific states which are communicated between children and parents through props, or you can take help from libraries like <strong>Redux</strong> and <strong>MobX</strong>. There are other options too, but these two are the most popular.</p><p>It completely depends on you, and how vast your app might be by the number of features. Using internal states is really easy to understand and use, but it gets difficult to track at scale. Imagine having a hundred screens using a hundred components. And now imagine using internal states here. And that’s why the likes of Redux or MobX were created. These sit on top of your whole app and provide you with stores and actions, which can be used by any of your components whenever needed.</p><p>I like both MobX and Redux, and I would be just fine using either of them. Use the one that fits your use case.</p><h4>Data Storage</h4><p>Redux and MobX both provide you with Stores, which are basically entities which store your data when you make calls to the API. This store is shared across components and make sure that all your data is available to you when you need it. They are saved in the memory, and are not persistent.</p><p>For persistent data, you can use databases or text files as usual. <strong>AsyncStorage</strong> of React Native is an API which works on top of a database. It stores key-value entities in your system. You will find yourself using this heavily for storing things like authentication tokens, persistent app states, etc. For example, keeping track of an intro screen which you show when the app is run for the first time.</p><h4>Styling</h4><p>Styling is rather straightforward. Think of CSS but in CamelCase instead of kebab-case. This is available to you through the inbuilt <strong>StyleSheet</strong> <strong>API</strong>.</p><p>If your plan of action also includes making a web application using react, you can very well use a popular library known as <a href="https://github.com/styled-components/styled-components"><strong>Styled Components</strong></a>. This lets you easily write styles using tagged template literals and CSS. This results in a 1:1 mapping between your style and your component, making it much easier to keep a track of.</p><p>The StyleSheet Way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*mcgJxMo8uTbs8ojKpf4VSA.png" /><figcaption>A little old-school, no?</figcaption></figure><p>The Styled Components Way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*Zaz6wwBtdCs9BuOaD3HY_w.png" /><figcaption>So cool :’)</figcaption></figure><h4>Networking</h4><p>To load data from the internet in your app, you need APIs to talk to it. React Native implicitly gives you support for fetch and WebSockets. Read the full tutorial <a href="https://facebook.github.io/react-native/docs/network.html">here</a>.</p><h3>Let’s talk about DEV Experience</h3><p>I have so much fun building using React Native primarily because of my ecosystem. On my primary monitor I have VS Code and the simulator. On my secondary monitor, I have my logs and debugger.</p><h4>Project Structure</h4><p>Project structure of your app is important to be figured out before you start developing it. There are a two well known alternatives, and they both have their advantages and use cases.</p><ul><li><strong>Folders by feature<br></strong>This should be your go-to project structure when you are talking about scalability. If your app has fifty features, you are better off keeping files related to all these features in separate folders. This makes finding files super easy.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*O2bKsdj2Hciok8KJg4YHEA.png" /><figcaption>Scalable indeed</figcaption></figure><ul><li><strong>Folders by type<br></strong>This is the most common structure you will see being used in boilerplates. Why? Because boilerplates don’t have enough code to split it by feature. So here, you would split your files under Components, Containers, Screens, Assets, etc. So in summary, this works great for small projects with less features.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*LguLM_aofMvp_cE_xTB5Kg.png" /><figcaption>Our Expo boilerplate structure</figcaption></figure><h4>Bug tracking</h4><p>Tracking bugs in production cannot be taken lightly. I recommend either <strong>Sentry</strong> or <strong>Bugsnag</strong> for React Native. Even Play Store will give you bug reports but it’s better to have one place to track all your bugs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*vlJsCQDHnTo2TVjpsrnDtA.png" /></figure><h4>Debugging</h4><p>For using the in-app developer tools, you can go through the tutorial given in the docs <a href="https://facebook.github.io/react-native/docs/debugging.html">here</a>. Also, make sure you try the <a href="https://github.com/jhen0409/react-native-debugger">React Native Debugger</a>.</p><h4>VS Code and React Native Tools</h4><p>React Native Tools is an absolutely amazing extension for VS Code. So many people simply use VS Code as a code editor. With tools like this, it can become a debugging powerhouse.</p><p>Using React Native tools, you can easily debug your code by putting breakpoints or watches, quickly run react-native commands from the command palette, and use IntelliSense to browse objects, functions and parameters for React Native APIs.</p><h4>Linting</h4><p>Do yourself a favour and use a linter. I use <strong>eslint</strong>. Yes, it gets annoying at times but over time you will automatically start writing correct code. This will simply prevent you from making stupid mistakes. It will tell you when you should have written a component as a functional component, or when you defined a variable and never used it.</p><p>Keep your codebase clean, and be a great host to a new developer who starts working with you on this project tomorrow.</p><p>There is so much to React Native. Here in this humble post, I have barely tried to scratch the surface. I have tried to talk about things that I know about in a summary. I hope this gave you an insight of the possibilities, and that this is enough for someone who is just starting out.</p><p>I am no master at React Native, but it’s always nice to share experience. If you have any questions, do ask them in the comments, and I will do my best to answer them.</p><h3>Thanks, human!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c859e939e4a2" width="1" height="1" alt=""><hr><p><a href="https://tech.treebo.com/bootstrapping-your-react-native-app-c859e939e4a2">Bootstrapping your React Native App</a> was originally published in <a href="https://tech.treebo.com/">Treebo Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>