<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: OGcodes</title>
    <description>The latest articles on Forem by OGcodes (@godswillokokon).</description>
    <link>https://forem.com/godswillokokon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F70664%2Fb65776b0-2af3-4754-8a8b-8e1da8f3d0c9.jpg</url>
      <title>Forem: OGcodes</title>
      <link>https://forem.com/godswillokokon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/godswillokokon"/>
    <language>en</language>
    <item>
      <title>UI Kitten: Eva Icons in React Native</title>
      <dc:creator>OGcodes</dc:creator>
      <pubDate>Tue, 23 Jun 2020 00:11:43 +0000</pubDate>
      <link>https://forem.com/godswillokokon/ui-kitten-eva-icons-in-react-native-hh5</link>
      <guid>https://forem.com/godswillokokon/ui-kitten-eva-icons-in-react-native-hh5</guid>
      <description>&lt;h2&gt;
  
  
  What is UI Kitten?
&lt;/h2&gt;

&lt;p&gt;UI Kitten is React Native library which is based on Eva Design System, it's an Open Source React Native framework of UI components, it enables you to create customizable amazing UI layouts, packed with an awesome set of general-purpose UI components, giving you more time to focus on business logic and other aspects of your app while it takes care of your app's looks and the themes can be toggled in the runtime, without need to reload the application, how cool is that?&lt;/p&gt;

&lt;p&gt;UI kitten being &lt;a href="https://eva.design/"&gt;Eva Design System&lt;/a&gt; based gives us consistency and scalability in the development and design process.&lt;/p&gt;

&lt;h2&gt;
  
  
  UI Kitten Specifications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;30+ general-purpose UI components with browser support for React Native Web.&lt;/li&gt;
&lt;li&gt;Theming System: Light, Dark and Custom.&lt;/li&gt;
&lt;li&gt;480+ general-purpose SVG Eva icons.&lt;/li&gt;
&lt;li&gt;Eva Design System support.&lt;/li&gt;
&lt;li&gt;UI Kitten Moment and Date functions: Modules allowing * UI Kitten components to work with dates.&lt;/li&gt;
&lt;li&gt;Both JavaScript and TypeScript Supported.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation &amp;amp; Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  New project:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;npx react-native init MyApp --template @ui-kitten/template-js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you build with TypeScript run :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx react-native init MyApp --template @ui-kitten/template-ts&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Existing project:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;yarn add @ui-kitten/components @eva-design/eva react-native-svg&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;if you use  Expo, you should use &lt;code&gt;expo install react-native-svg@9.13.6&lt;/code&gt; to install SVG package.&lt;/p&gt;

&lt;p&gt;We will need to restart our bundler to make sure changes are made&lt;/p&gt;

&lt;p&gt;&lt;code&gt;yarn start --reset-cache&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up our application root
&lt;/h2&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Output
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yf_v0CkN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AQWgrUKn40m0DG83uCGm0Ug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yf_v0CkN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AQWgrUKn40m0DG83uCGm0Ug.png" alt="Hello Kitten"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Eva Icons:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://akveo.github.io/eva-icons/#/"&gt;Eva Icons&lt;/a&gt; is a pack of 480+ beautiful icons, UI kitten has it as a module for React Native applications to add it's Open Source, using Eva will enable full consistency with Eva Design System.&lt;/p&gt;

&lt;p&gt;Eva Icons supports 4 animation types&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Zoom.&lt;/li&gt;
&lt;li&gt;Pulse.&lt;/li&gt;
&lt;li&gt;Shake.&lt;/li&gt;
&lt;li&gt;Infinite.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Eva Icon Installation &amp;amp; Usage
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install Eva Icons:
&lt;code&gt;yarn add @ui-kitten/eva-icons&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Implementation:
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Rebuild bundle:
&lt;code&gt;npx react-native run-android or npx react-native run-ios&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1jBPvZCk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ADyOVjeCzleipKpfib1RO9g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1jBPvZCk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ADyOVjeCzleipKpfib1RO9g.png" alt="Icon"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Animated Icons:
&lt;/h2&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Root file:
&lt;/h2&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eb8Yshhc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Akso8olf6yWSznoqMDgIa7Q.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eb8Yshhc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Akso8olf6yWSznoqMDgIa7Q.gif" alt="animate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;UI Kitten has a beautiful and rich &lt;a href="https://akveo.github.io/react-native-ui-kitten/docs/getting-started/what-is-ui-kitten#what-is-ui-kitten"&gt;documentation&lt;/a&gt;, do check it out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Thanks for reading
&lt;/h2&gt;

&lt;p&gt;I hope this was helpful, don't forget to like and share this article, you can tweet at &lt;a href="https://twitter.com/GodswillOkokon"&gt;@Godswillokokon&lt;/a&gt; if you have any questions or drop a comment below.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>ux</category>
      <category>design</category>
    </item>
    <item>
      <title>React Native: What You Need To Know About Hermes.</title>
      <dc:creator>OGcodes</dc:creator>
      <pubDate>Sun, 10 May 2020 16:04:47 +0000</pubDate>
      <link>https://forem.com/godswillokokon/react-native-what-you-need-to-know-about-hermes-4lhn</link>
      <guid>https://forem.com/godswillokokon/react-native-what-you-need-to-know-about-hermes-4lhn</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;TL;DR:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://hermesengine.dev/"&gt;Hermes&lt;/a&gt; is an open-source lightweight JavaScript engine optimized for &lt;a href="https://reactnative.dev/"&gt;React Native&lt;/a&gt; built by Facebook, It improves performance by decreasing memory utilization, reduces download size, and decreases TTI (Time To Interaction).&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you are new to React Native and want to get started, &lt;a href="https://reactnative.dev/"&gt;here is a good resource&lt;/a&gt; you will find helpful.&lt;/li&gt;
&lt;li&gt;For Windows users, make sure you have &lt;a href="https://www.microsoft.com/en-us/download/details.aspx?id=48145"&gt;Microsoft Visual C++ 2015 Redistributable&lt;/a&gt; installed, you can check if it is installed by searching for &lt;strong&gt;“Microsoft Visual C++ 2015 Redistributable”&lt;/strong&gt; after pressing the Windows key.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L2XjBRWN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AYqngdA6_P1p2LPjQFsGsRw.jpeg" alt="Microsoft Visual"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;On the 11th of July 2019, At &lt;a href="https://infinite.red/ChainReactConf"&gt;Chain React 2019&lt;/a&gt;, &lt;a href="https://github.com/facebook/hermes"&gt;Hermes&lt;/a&gt; JavaScript engine was announced running on React Native, It was first used internally by Facebook before it went open source. Before this, the React Native team at Facebook analyzed performance data and noticed that the JavaScript engine itself was a significant factor in start-up time and download size.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why you should use Hermes
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;We built a new JavaScript engine we call Hermes. It is &lt;br&gt;
designed to improve app performance, focusing on our &lt;br&gt;
React Native apps, even on mass-market devices with &lt;br&gt;
 limited memory, slow storage, and reduced computing &lt;br&gt;
power.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Facebook Team&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ey-TmBbG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AdoHfV1S6Vx9Xo3x8l7nJCQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ey-TmBbG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AdoHfV1S6Vx9Xo3x8l7nJCQ.png" alt="hermes used"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The three main architecture Facebook focus on improving are :
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Adapting garbage collection to mobile OSes constraints.&lt;/li&gt;
&lt;li&gt;Ditching the JIT (just-in-time) compiler.&lt;/li&gt;
&lt;li&gt; Precompiling the JavaScript source code.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Adapting garbage collection came with many reasons
&lt;/h2&gt;

&lt;p&gt;Hermes adapting garbage collection aids to reduce the overall virtual memory consumption by implementing on-demand allocation in non-contiguous chunks that can be moved around and returned to the OS when no longer needed, Operating systems aggressively kill applications that use too much memory. When apps are killed, slow restarts are required and background functionality suffers.&lt;/p&gt;

&lt;p&gt;The following are the features of the garbage collector :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On-demand allocation: Allocates VA (virtual address) space in chunks only as needed.&lt;/li&gt;
&lt;li&gt;Noncontiguous: VA (virtual address) space need not be in a single memory range, which avoids resource limits on 32-bit devices.&lt;/li&gt;
&lt;li&gt;Moving: Being able to move objects means the memory can be defragmented and chunks that are no longer needed are returned to the operating system.&lt;/li&gt;
&lt;li&gt;Generational: Not scanning the entire JavaScript heap reduces time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why ditching the JIT compiler helps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A JIT compiler warm-up when an application starts, they have issues improving TTI and may even hurt TTI more by increasing it.&lt;/li&gt;
&lt;li&gt;A JIT compiler adds to native code size and memory consumption, which negatively affects primary metrics.&lt;/li&gt;
&lt;li&gt;A JIT compiler is likely to hurt the metrics we care about most, so Facebook chose not to implement it. Instead of focusing on interpreter performance as the right trade-off for Hermes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Precompiling the JavaScript source code into bytecode helps.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Parsing and compilation directly reduce the time spent on any tasks at launch time.&lt;/li&gt;
&lt;li&gt;Since the precompilation phase has more relaxed time constraints, bytecode generated is usually smaller and more efficient, this aids the compiler to apply whole-program optimizations such as function deduplication and string table packing.&lt;/li&gt;
&lt;li&gt;Hermes bytecode can be mapped into memory without requiring to read the whole file in advance, which brings a huge improvement with slow flash memories and reduces the chances of an app being killed by the OS due to excessive memory usage which was an issue before now in React Native.&lt;/li&gt;
&lt;li&gt;Hermes tries to be efficient through bytecode precompilation — rather than loading JavaScript and then parsing it. Hermes employs ahead-of-time (AOT) compilation during the mobile app build process to allow for more extensive bytecode optimization. Similar to the Fuchsia Dart compiler for iOS which is also an AOT compiler.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--btJx5Uj1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://miro.medium.com/max/1400/1%2A9JsNQY1MRpKmM_yeBvUXrA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--btJx5Uj1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://miro.medium.com/max/1400/1%2A9JsNQY1MRpKmM_yeBvUXrA.gif" alt="Bytecode precompilation with Hermes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hermes for iOS
&lt;/h2&gt;

&lt;p&gt;Before version 0.64, Hermes did not have support for iOS and that is because Apple is forced to use &lt;a href="https://trac.webkit.org/wiki/JavaScriptCore"&gt;JavaScriptCore&lt;/a&gt; and not &lt;a href="https://v8.dev/"&gt;V8&lt;/a&gt; like Android devices.&lt;/p&gt;

&lt;p&gt;JavaScriptCore is an optimizing virtual machine and it’s the built-in engine for &lt;a href="https://webkit.org/"&gt;Webkit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;WebKit is a browser engine used in the Safari web browser and every other iOS browser, it was built by Apple in C++ and runs on macOS, iOS, and Linux.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fun-Fact:&lt;/strong&gt; This engine was used by BlackBerry.&lt;/p&gt;

&lt;p&gt;On the other hand, V8 is an open-source WebAssembly and JavaScript engine, it was built by Google in C++ also. V8 is used in Node.js and it runs on Chrome, Chromium, and lately, it is what powers the Microsoft Edge browser.&lt;/p&gt;

&lt;p&gt;V8 implements &lt;a href="https://webassembly.github.io/spec/core/"&gt;WebAssembly&lt;/a&gt; and &lt;a href="https://tc39.es/ecma262/"&gt;ECMAScript&lt;/a&gt;, and runs on Windows, macOS, and Linux.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hermes opt-in on iOS
&lt;/h2&gt;

&lt;p&gt;It’s 2021🎊🎊 and with the release of &lt;a href="https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#v0640"&gt;version 0.64&lt;/a&gt; we are happy to now use Hermes to build on iOS as well. To enable Hermes on iOS, set &lt;code&gt;hermes_enabled&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; in your &lt;code&gt;Podfile&lt;/code&gt; and &lt;code&gt;run pod install&lt;/code&gt;.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Hermes with Proxy Support
&lt;/h2&gt;

&lt;p&gt;We now have Proxy support to Hermes, enabling compatibility with popular community projects like react-native-firebase and mobx. If you have been using these packages you can now migrate to Hermes for your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hermes for Android
&lt;/h2&gt;

&lt;p&gt;Setting up Hermes is seamless and easy.&lt;br&gt;
According to React Native’s awesome documentation, we will first start by editing our &lt;strong&gt;android/app/build.gradle&lt;/strong&gt; file and setting &lt;strong&gt;enableHermes&lt;/strong&gt; to &lt;strong&gt;true&lt;/strong&gt; like so :&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;If we use ProGuard in our application, we will have to add rules in &lt;strong&gt;android/app/proguard-rules.pro&lt;/strong&gt; like so :&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;For these changes to take effect we will need to clean build, so in our terminal, we will do like so :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ cd android &amp;amp;&amp;amp; ./gradlew clean&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Finally, we are ready to build and test our app and we will do like so :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ npx react-native run-android&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Confirming if Hermes is enabled in our project
&lt;/h2&gt;

&lt;p&gt;If we created a new app with &lt;code&gt;$ npx react-native init AppName&lt;/code&gt; before setting up Hermes we will see that Hermes is enabled at the top-right corner of our app screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s68A3gXT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/810/1%2AGiRvjRSIIS8g1Fr8vkeuJQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s68A3gXT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/810/1%2AGiRvjRSIIS8g1Fr8vkeuJQ.jpeg" alt="hermes app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But if we had an existing project we can still test by making use of the global &lt;strong&gt;HermesInternal&lt;/strong&gt; variable like so :&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;To see full benefits why we use Hermes, you can build a release version of your app to compare the differences and see improvements in app startup time and bundle size like so :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ npx react-native run-android --variant release&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article we have an understanding of the following things :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We now have Hermes Support for both Android and iOS.&lt;/li&gt;
&lt;li&gt;Difference between Interpretation with React Native conventional engine and Bytecode precompilation with Hermes.&lt;/li&gt;
&lt;li&gt;What Hermes does under the hood.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;I will like to thank &lt;strong&gt;Tzvetan Mikov, Will Holen,&lt;/strong&gt; and the rest of the Hermes team on their work to making Hermes a success.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Thanks for reading
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kIjAFGQA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/64/0%2A-MJS0GQehF-Ry1b3" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kIjAFGQA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/64/0%2A-MJS0GQehF-Ry1b3" alt="With Love"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this was helpful, don’t forget to like and share this article, you can tweet at &lt;a href="https://twitter.com/GodswillOkokon"&gt;@Godswillokokon&lt;/a&gt; if you have any questions or drop a comment below.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>hermes</category>
      <category>android</category>
      <category>ios</category>
    </item>
    <item>
      <title>React Native : How to upload an image to Cloudinary.</title>
      <dc:creator>OGcodes</dc:creator>
      <pubDate>Mon, 30 Mar 2020 01:09:23 +0000</pubDate>
      <link>https://forem.com/godswillokokon/react-native-how-to-upload-an-image-to-cloudinary-4okg</link>
      <guid>https://forem.com/godswillokokon/react-native-how-to-upload-an-image-to-cloudinary-4okg</guid>
      <description>&lt;h1&gt;
  
  
  Prerequisites
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Things you need to know are:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Familiar with React Native elementary setup, if not get started here, You can also check React Native awesome documentation here.&lt;/li&gt;
&lt;li&gt;Basic understanding of Hooks, if not get started here.&lt;/li&gt;
&lt;li&gt;Little or no knowledge of Cloudinary.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools Required ⚒️
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Node &amp;gt;= v13.0.0.&lt;/li&gt;
&lt;li&gt;React &amp;gt;= v16.9.0.&lt;/li&gt;
&lt;li&gt;React Native CLI &amp;gt;= v0.61.5.&lt;/li&gt;
&lt;li&gt;Android Studio, VSCode.&lt;/li&gt;
&lt;li&gt;I will be using VSCode, You can download here.&lt;/li&gt;
&lt;li&gt;If you are using VSCode, I use Lights Out theme by Nedy, Lovely theme.&lt;/li&gt;
&lt;li&gt;Cloudinary Dashboard. You can signup here, If you do not have an account.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;In this article, we will be uploading an image from a mobile camera or gallery collection to Cloudinary using React Native, We will be using hooks to manage state to display the image after it is uploaded.&lt;/p&gt;

&lt;p&gt;Cloudinary is an end-to-end image and video management solution for websites and mobile apps, covering everything from image and video uploads, storage, manipulations, optimizations to delivery, It provides a secure and comprehensive API for easily uploading media files from server-side code, directly from the browser or from a mobile application.&lt;/p&gt;

&lt;p&gt;Using Cloudinary's upload capabilities, you can upload media assets in bulk with a variety of options for customizing how they will be uploaded, including naming, whether to apply manually specified or automatically generated tags and metadata, whether to apply incoming transformations or other AI-based analysis of the uploaded assets, and more.&lt;/p&gt;

&lt;p&gt;We can look at Cloudinary as our cloud storage for media files (images, videos, PDFs, text documents, GIFs), But in this article we will be working with only images. &lt;/p&gt;

&lt;h1&gt;
  
  
  Overview on what we are building
&lt;/h1&gt;

&lt;p&gt;We are building a React Native app that takes an image from a device, stores it on Cloudinary and then renders it to the screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aGsqqffP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585309289733_Screenshot_1585205956.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aGsqqffP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585309289733_Screenshot_1585205956.png" alt="overview.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s get started 😊
&lt;/h2&gt;

&lt;p&gt;We have a boilerplate code, which will save us time in creating a React Native project and also setting up our screen styles, you can clone the repo  here.&lt;/p&gt;

&lt;h1&gt;
  
  
  Setting up Image Picker ⚙️
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Let’s install React Native Image Picker :
yarn add react-native-image-picker&lt;/li&gt;
&lt;li&gt;We will have to give the app some permissions to enable camera and storage rights. We will add those permissions in the AndroidManifest.xml located in android/app/main/AndroidManifest.xml. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s-qXoz_t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585221675274_xml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s-qXoz_t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585221675274_xml.png" alt="AndroidManifest.xml"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;We will import ImagePicker from 'react-native-image-picker' in App.js&lt;/li&gt;
&lt;li&gt;Now we have to fix up our Image Picker, ImagePicker.showImagePicker will be needing two arguments

&lt;ol&gt;
&lt;li&gt;First we have options which is an object for customizing the image picker, it can be omitted for a default options.&lt;/li&gt;
&lt;li&gt;Our second argument is a callback that sends an object in response.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Let’s write some code in the App.js :&lt;/li&gt;
&lt;li&gt;From our boilerplate code we should have this :
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is some starter code that will cover UI layout and styles. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now we will add our Image Picker to the code : &lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;From the code above we have a function called selectPhotoTapped which bodies all our Image Picker code.&lt;/p&gt;

&lt;p&gt;In selectPhotoTapped function we have an object called options as explained earlier, it’s an object for customizing the image picker.&lt;/p&gt;

&lt;p&gt;Moving forward we have to access the method showImagePicker from ImagePicker, showImagePicker displays the image picker and has two arguments, options and a response object.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After understanding how our image picker works, let’s see it work by calling the selectPhotoTapped function which will be triggered by a TouchableOpacity press event.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will be logging out a response from both line 12 and source from line 23.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  Demonstration
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aGsqqffP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585309289733_Screenshot_1585205956.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aGsqqffP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585309289733_Screenshot_1585205956.png" alt="overview.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Output :
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yD-SNTH9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585234261481_log.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yD-SNTH9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585234261481_log.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The data between the red lines is what we are interested in, The first log response is the entire response from Image Picker, The second log is specific data that we will be using later in future of this article it consists of three properties :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;type&lt;/li&gt;
&lt;li&gt;uri&lt;/li&gt;
&lt;li&gt;Now we are ready for our cloudinary setup. 🎉 🎉 🎉
&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Setting up Cloudinary ⚙️
&lt;/h1&gt;

&lt;p&gt;Just to let us know, uploading to Cloudinary is done over HTTPS using a secure protocol based on your account's cloud_name, api_key and api_secret parameters, or using an unsigned upload without an authentication signature. When using Cloudinary's SDKs, The three security parameters are generally configured globally.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To begin our setup we will need to create an account using this link if we do not have one already. &lt;/li&gt;
&lt;li&gt;After the Signup or Sign in process, we should see our dashboard like so :&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xB7e_CzR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585295692845_dash.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xB7e_CzR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585295692845_dash.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We click on the settings icon at the right section of the top navbar, Then we will navigate to the upload tab we should see : &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IjygFwuk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585296190315_uplo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IjygFwuk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585296190315_uplo.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We scroll down to where we will find Upload presets, and click Add new preset :&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LWRGWEvD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585297854920_preset.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LWRGWEvD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585297854920_preset.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I recommend changing Upload preset name to a custom name, and also setting Signing Mode to unsigned, this will allow us to upload to Cloudinary without an authentication signature and then save it like so :&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D2H3QGm9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585298533936_save.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D2H3QGm9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585298533936_save.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now we are done with the Cloudinary settings, Our next step, We need to create a FormData so we can upload our image and cloudinary presets.&lt;/li&gt;
&lt;li&gt;First, we start by setting the state for the photo, In this article, we will be using hooks.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Next up we are creating our Cloudinary function, we will first create a FormData and append our image file, Cloudinary presets and cloud name.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Next up we have to upload our data to our Cloudinary API using a fetch method. We can get our base API and cloud name here : &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DfTR-yHX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585303157765_api.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DfTR-yHX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_03FCFC0ECCDF18A13688BB1130411C299ABC90A4CF4D82C04902E488C4300DED_1585303157765_api.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uploading our data to Cloudinary, we will be making a POST request to our base API like so :&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;From the code above we did a POST request to our base API and from the response data we will be making use of only secure_url  and we updated the state of our photo.&lt;/li&gt;
&lt;li&gt;Now we have our function set up, In the selectPhotoTapped function, we will be calling cloudinaryUpload and passing our image data as an argument.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Finally we can take a look at our entire code and have a rundown on the steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We set up our UI layout.&lt;/li&gt;
&lt;li&gt;We installed Image Picker from React Native.&lt;/li&gt;
&lt;li&gt;We set up our Image Picker and tested it.&lt;/li&gt;
&lt;li&gt;We set up our Cloudinary presets.&lt;/li&gt;
&lt;li&gt;We fix up our Cloudinary in our code by sending a request to our base API.&lt;/li&gt;
&lt;li&gt;We got the response and use it to update our image display.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the complete code, feel free to send a pull request if you like to add something to what we have.&lt;/p&gt;

&lt;h1&gt;
  
  
  Thanks for reading ❤️
&lt;/h1&gt;

&lt;p&gt;Hope this helps, you can tweet at &lt;a class="comment-mentioned-user" href="https://dev.to/godswillokokon"&gt;@godswillokokon&lt;/a&gt;
 if you have any questions.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>reactnativeimagepicker</category>
      <category>cloudinary</category>
      <category>howto</category>
    </item>
  </channel>
</rss>
