<?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 Jun Kaneko on Medium]]></title>
        <description><![CDATA[Stories by Jun Kaneko on Medium]]></description>
        <link>https://medium.com/@goodpic?source=rss-9a145dd5d7e9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LS39oLFmlKZwifjK.jpg</url>
            <title>Stories by Jun Kaneko on Medium</title>
            <link>https://medium.com/@goodpic?source=rss-9a145dd5d7e9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 04:36:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@goodpic/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[Understanding React Native Architecture]]></title>
            <link>https://medium.com/@goodpic/understanding-react-native-architecture-8d9869da044b?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d9869da044b</guid>
            <category><![CDATA[react-native-testing]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-navigation]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Sun, 16 Aug 2020 10:16:21 GMT</pubDate>
            <atom:updated>2020-08-16T10:16:21.389Z</atom:updated>
            <content:encoded><![CDATA[<p>React Native is an excellent entering point to app development for a web developer, especially with React experiences.<br>However, it does not mean that React Native is simple. You can write apps with your familiar language, JavaScript, but it certainly requires an overall understanding of iOS and Android platforms. This article is a summary of my learning process on the React Native architecture and the ecosystem from the web developer point of view.</p><h3>The Execution Environments</h3><p>React runs on the JavaScript runtime environment. For the web, it is a web browser. There is a single JavaScript thread, and it uses web APIs implemented natively in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPeYttkzFiHQhJ24eY1H9w.png" /></figure><p>It is important to understand how the callbacks work between the main JS thread and Web APIs, especially when using asynchronous functions. This interaction between JavaScript engine and native APIs are also vital to understand how React Native behaves in its environment.</p><h3>Threads in React Native</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_Y199NeO2bJrwCZCsgw8Q.png" /></figure><p>There are three key threads in React Native execution environment, JavaScript thread, Native main thread and the background thread to handle Shadow Node. <br>In the current architecture, the communication between these threads happens over the library called “bridge”.</p><p>The React Native team is actively working on the major architecture upgrade, and <a href="http://blog.nparashuram.com/2019/01/react-natives-new-architecture-glossary.html">this article gives a great overview of why and how the change is needed</a>.<br>I don’t get into the details, but the basic understanding of the current and future architecture helps to model your application, especially to separate the concerns.</p><h3>React and React Native</h3><p>As you can see above, React Native covers a significantly broader area than React itself.</p><p>React for the web looks rather intuitive as the key concept, the Virtual DOM, implies the browsers’ HTML dom rendering. But in-fact, the Virtual DOM is not tied to the HTML DOM (Document Object Model). <a href="https://reactjs.org/docs/faq-internals.html">The Virtual DOM in React is more of a programming concept or a pattern than a specific technology.</a></p><p>It provides an abstraction for the declarative UI. The virtual representation of a UI is kept in memory and synced with the external UI libraries. This process is called <a href="https://reactjs.org/docs/reconciliation.html">reconciliation</a>.</p><p>Here is a good explanation form<a href="https://github.com/acdlite/react-fiber-architecture"> the React Fiber Architecture</a>.</p><blockquote><strong>Reconciliation versus rendering</strong></blockquote><blockquote>The DOM is just one of the rendering environments React can render to, the other major targets being native iOS and Android views via React Native. (This is why “virtual DOM” is a bit of a misnomer.)</blockquote><blockquote>The reason it can support so many targets is because React is designed so that reconciliation and rendering are separate phases. The reconciler does the work of computing which parts of a tree have changed; the renderer then uses that information to actually update the rendered app.</blockquote><blockquote>This separation means that React DOM and React Native can use their own renderers while sharing the same reconciler, provided by React core.</blockquote><blockquote>Fiber reimplements the reconciler. It is not principally concerned with rendering, though renderers will need to change to support (and take advantage of) the new architecture.</blockquote><h3>React Native Components and React Navigation</h3><p>React Native provides its own UI abstraction layer over iOS and Android platforms. React Native core and native components invoke the native views so that you can write the smartphone app UI with JavaScript, instead of Kotlin/Java or Swift/Objective-C.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U1kbROulNkXfLW5OpfZlNA.png" /><figcaption><a href="https://reactnative.dev/docs/intro-react-native-components">Core Components and Native Components</a></figcaption></figure><p>The native components cover comprehensive native UI elements, but you still need to write a lot of code to simulate the native user experience such as tab navigation. That’s where React Navigation comes in.</p><p><a href="https://reactnavigation.org/docs/pitch">React Navigation is a pure JavaScript library which does not include any native code</a>. It is built on the other native libraries such as <a href="https://software-mansion.github.io/react-native-reanimated/">Reanimated</a>, <a href="https://software-mansion.github.io/react-native-gesture-handler/">Gesture Handler</a>, and <a href="https://github.com/software-mansion/react-native-screens">Screens</a> to implement the common app navigation patterns.</p><p>It provides the best practice of how to structure and navigate the app screens, which is one of the most confusing parts when you come from a web development background. <br>My advice is to stick to the basic navigation patterns until you are confident, and you can implement your custom navigators on top of React Navigation once you have the good overviews. I would also prefer to place navigators and screens into the dedicated directories to clearly separate them from the other components.</p><h3>Thinking in React</h3><p>Despite the difference in the UI implementations, the thought process of building a new application stays the same as “<a href="https://reactjs.org/docs/thinking-in-react.html">Thinking in React</a>” way.</p><ol><li>Start With A Mock</li><li>Break The UI Into A Component Hierarchy</li><li>Build A Static Version in React</li><li>Identify The Minimal (but complete) Representation Of UI State</li><li>Identify Where Your State Should Live</li><li>Add Inverse Data Flow</li></ol><h3>Hooks and Functional Component</h3><p>React 16.8.0 introduced Hooks in 2019, and it was a big paradigm shift. The React team expects Hooks to replace all the Class Component use cases, and the popular libraries have already migrated toward this direction, for example, React Navigation 5.0 and React Redux 7.1.0 introduced their Hook APIs.</p><p>Conceptually, React components have always been closer to functions, and “<a href="https://reactjs.org/docs/thinking-in-react.html">Thinking in React</a>” way became more straight forward with Hooks.</p><p><a href="https://reactjs.org/docs/hooks-intro.html">The motivation behind Hooks</a> explains the benefits:</p><blockquote><strong>Hooks let you split one component into smaller functions based on what pieces are related (such as setting up a subscription or fetching data)</strong>, rather than forcing a split based on lifecycle methods. You may also opt into managing the component’s local state with a reducer to make it more predictable.</blockquote><h3>Component Side Effects and Closure</h3><p>Based on the prototype inheritance, JavaScript functions are said to be the first-class citizens which means that they can be:</p><ul><li>assigned to variables</li><li>used as functional parameters</li><li>returned from a function</li></ul><p>These are equally applied to React’s Functional Component. JavaScript’s Closure is also an essential element when using Hooks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NYQvQroPo4zAymi86CKBuQ.png" /></figure><blockquote>A <strong>closure</strong> is the combination of a function bundled together (enclosed) with references to its surrounding state (the <strong>lexical environment</strong>). In other words, a closure gives you access to an outer function’s scope from an inner function. <strong>In JavaScript, closures are created every time a function is created</strong>, <strong>at function creation time</strong>. (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures">MDN Web docs: Closures</a>)</blockquote><p>Like <a href="https://reactjs.org/docs/hooks-faq.html#what-can-i-do-if-my-effect-dependencies-change-too-often">this example in Hooks FAQ</a>, it is very important to understand when the closure is created in the component lifecycle and use the stable function instead of unstable state variables within Hooks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kEWXXWmIy7X09EbjEXHPwg.png" /></figure><blockquote><strong>Note: </strong>Unlike the setState method found in class components, useState does not automatically merge update objects. You can replicate this behavior by combining the function updater form with object spread syntax:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*9ealwgvPpZNP7oAdUDztOA.png" /></figure><p>React also provides <a href="https://reactjs.org/docs/context.html">Context API to share data that can be considered “global”</a> for a tree of React components, such as the current authenticated user, theme, or preferred language.</p><h3>Referential Transparency and Static Type Checking</h3><p>JavaScript is multi-paradigm, Object-Oriented Programming and Functional Programming, and React has been inherited the strength of both. But with Hooks, I feel that it is more opinionated toward the functional programming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z7vn2mjI7KKE9dC_8uurrg.png" /></figure><blockquote>The key feature of React is composition of components. Components written by different people should work well together. It is important to us that you can add functionality to a component without causing rippling changes throughout the codebase. (<a href="https://reactjs.org/docs/design-principles.html">React Design Principles</a>)</blockquote><p>By <a href="https://reactjs.org/docs/hooks-reference.html">extracting side effects</a> from a React component, it becomes more predictable. You can expect the component to render the same output if the input is the same. In more specific words, it can gain referential transparency, or be idempotent.</p><p>In practice, the referential transparency should be assured by the static type checking and sufficient unit testing.</p><p>Static type checkers and linters, my preference is TypeScript and ESLint, make the development experience more confident and solid as they can identify certain types of problems before you even run your code.</p><p>Although the configuration could be a bit cumbersome when you start a new project, it helps you and your team to be much more productive. I don’t see any reason not to use them in 2020.</p><h3>Component Tests</h3><p>A declarative component is easier to write the test as you can focus on the pure interaction and rendering of the component.</p><blockquote><strong>With Hooks, you can extract stateful logic from a component so it can be tested independently and reused. </strong>Hooks allow you to reuse stateful logic without changing your component hierarchy. (<a href="https://reactjs.org/docs/hooks-intro.html">The motivation behind Hooks</a>)</blockquote><p>I believe that <a href="https://callstack.github.io/react-native-testing-library/">React Native Testing Library</a> is now a defacto testing library for React Native. It integrates closely with Jest and provides clear testing methodologies along with the popular libraries such as <a href="https://callstack.github.io/react-native-testing-library/docs/react-navigation">React Navigation</a> and <a href="https://callstack.github.io/react-native-testing-library/docs/redux-integration">Redux</a>.</p><ul><li><a href="https://reactjs.org/docs/test-renderer.html">React Test Renderer</a> is developed alongside React core. It renders React components to pure JavaScript objects, without depending on the DOM or a native mobile environment.</li><li><a href="https://callstack.github.io/react-native-testing-library/">React Native Testing Library</a> (or RNTL) is built on top of React Test Renderer. It adds useful APIs such as to render ( to getByText, queryAllByA11yRole, …), fireEvent, waitFor, and act. It is opinionated to focusing on user experience and accessibility.</li><li><a href="https://github.com/testing-library/react-hooks-testing-library">React Hooks Testing Library</a> to write test custom hooks that are not directly tied to a component or complex that is difficult to test through component interactions.</li></ul><h3>Conclusion</h3><p>I understand that there has been and will be always a debate between React Native vs Native App development.</p><p>But as a JavaScript developer, React and React Native itself is a very interesting and inspiring framework to learn. It is leveraging the JavaScript’s capability at the maximum level and packed with the best practices.</p><p>Through the learning process, I felt like gaining a more in-depth understanding of JavaScript language itself. I hope that this article may convey excitement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d9869da044b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Scaled Our Retail Operations With Cloud and App Platforms During the Lockdown]]></title>
            <link>https://medium.com/firebase-developers/how-we-scaled-our-retail-operations-with-cloud-and-app-platforms-during-the-lockdown-589cc66d7747?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/589cc66d7747</guid>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[retail-technology]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Tue, 23 Jun 2020 21:52:50 GMT</pubDate>
            <atom:updated>2020-07-03T13:56:20.980Z</atom:updated>
            <content:encoded><![CDATA[<h4>Case Study</h4><p>It has been an unprecedented year for everyone, and for me, it was one of the busiest periods as a hands-on engineering/e-commerce manager.</p><p>Before the memory fades, I want to share my experience of how technology helped to scale <a href="https://www.japancentre.com/en">our retail (3 stores and online/wholesale)</a> and <a href="https://www.shoryuramen.com/">hospitality business (10 restaurants)</a> during this pandemic period with two engineers including myself.</p><p>Here are some of the highlights:</p><ul><li>The number of <strong>online orders increased to five times higher</strong> than usual.</li><li>The fulfilment <strong>team scaled up from 20 to 60 staffs</strong> to cope with the surged demand, in two weeks.</li><li>The import container from Japan stopped, and the purchasing team needed a <strong>full sales and demand analysis of all 3000+ inventories</strong> to switch to the local suppliers.</li><li>Launched fresh <a href="https://www.japancentre.com/en/products/15986-diy-shoryu-kit-shoryu-ganso-ramen"><strong>Ramen DIY kit</strong></a> delivery as all of the 12 restaurants were closed, and the first 250 slots were <strong>sold out just in 30 minutes</strong>.</li></ul><p>All of these were not achievable if we haven’t built our e-commerce and smartphone app-based fulfilment system in-house on the cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*be1yS0G4JYgLCPifq2Wm9Q.png" /><figcaption>The system overview</figcaption></figure><h3>Aggregate Every Data Into BigQuery</h3><p>When I joined the company almost three years ago, all the systems and data were scattered, and there was even no way to figure out how much one product was sold in the business for a day.</p><p>So I started to consolidate the EPOS systems and aggregate all the sales data into the data warehouse, Google Big Query. Although the most EPOS system provides the analysis and reporting functions, none of the existing solutions in the market suited to our requirements. They are either optimised for retail or hospitality (restaurants) use cases, but our business is a mixture of them as well as online stores and wholesale of imported food.</p><p>So we decided to aggregate all the transaction data, not limited to the sales but also internal procurement transactions between the warehouse/central kitchen and stores/restaurants, then designed the dedicated dashboards for each department. The dashboards are a combination of Google Data Studio and automated Google spreadsheet reports triggered by Cloud Functions.</p><h3>The Real-Time Dashboard to Control the Kitchen Production</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j64tB_vL1pdVkiPdOjYwFA.png" /></figure><p>The real-time dashboard changed every operation in the company; for example, it reduced the food wastage significantly as the kitchen can fully control the production based on the ongoing demand during the day.</p><p>However, the real strength we appreciated during the pandemic period was Big Query’s powerful online query editor and Google sheet integration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*PsfTcBlou9agYWNRvKccrg.png" /></figure><p>Since the lockdown changed customer behaviours completely, I needed to scrap and build a new KPI dashboard almost every week as the various circumstances change dramatically. The real-time big data analysis helped a lot to guide and give confidence in the executive decisions.</p><p>Especially when collaborating with remote working colleagues, well-processed data is essential for productive and positive decision making.</p><h3>React Native App to Scale the Warehouse Operations</h3><p>Another key technology which helped to scale the fulfilment operation was our in-house developed smartphone app built with React Native (<a href="https://expo.io/">Expo.js</a>) on iPod touch + scanner device attached.</p><p>Our online store sells a unique selection of Japanese food. The products directly imported from Japan are fun to see, but the foreign packages become tricky when they come to be picked by non-Japanese speakers in the warehouse.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o-9XJIHeubcjPo2ThZsUOA.png" /><figcaption>iOS Scanner app</figcaption></figure><p>We have developed the iOS app to pick the online orders and been improving the usability over the past year.</p><p>This app played an essential role to scale the fulfilment team from 20 to 60 staffs in two weeks. It instructs everything, which shelf to go, what to pick, check the best-before date, where to place the basket and so on. A new starter can join the operation without any prior knowledge, just by scanning the barcodes of the picking sheets and products.</p><p>We could shift all the experienced staffs to the packing process, as it requires skills, and recruit the 40 extra help staffs from our closed restaurants during the lockdown.</p><p>From the system point of view, what we needed was to order 20 extra iPod touch and the scanner module online, assemble, and install the enterprise iOS app.</p><p>In two weeks, we were able to dispatch five times more orders a day, though there was a huge hustle to redesign the operational area to accommodate three times more staffs while keeping the social distancing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4M9eRjWby82BENKjJ_u43w.jpeg" /></figure><h3>Bridge Systems With GraphQL and Cloud Functions</h3><p>The app looks simple when using, but it connects to three different systems, online store, wholesale store and the warehouse management system, thus three different data schemas.</p><p>We added GraphQL API to all the systems built on Ruby on Rails, and the initial version of the app was accessing GraphQL APIs directory via Apollo client. But soon it became a nightmare to maintain multiple endpoints and GraphQL schemas within an app.</p><p>So I decided to move the data processing layer to Firebase Functions to act as the API gateway to aggregate the data. The functions fetch the data from multiple GraphQL endpoints, parse and store in FireStore as the unified database.</p><h3>Sync the Consistent Data With FireStore + TypeScript</h3><p>FireStore works quite interestingly with React Hooks. If you store some of React Component state to the FireStore table, it can be easily synced between multiple app installations by subscribing the record.</p><p>For example, when picking a large wholesale order containing 200+ products, as many as pickers can join in swarming way by sharing the picking process between their apps.</p><p>It is always tricky to update the API and the client separately. TypeScript helped a lot to maintain the data consistency between the backend (Node.js) and the app (React Native). It is much more manageable if both ends maintain the unit tests based on the shared types, even when making a change on the data structure.</p><h3>Scaling the Business, Not Only the System</h3><p>What I have learnt from this pandemic operation was that scalability is not only about web performance. The scalable system is a combination of structured data, cloud architecture, end-user usability and most importantly, physical operations.</p><p>Thanks to all the cloud solutions, any traditional business could be redesigned to scale if it is fully rebuilt on the new paradigm, even if you are not tech giant.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=589cc66d7747" width="1" height="1" alt=""><hr><p><a href="https://medium.com/firebase-developers/how-we-scaled-our-retail-operations-with-cloud-and-app-platforms-during-the-lockdown-589cc66d7747">How We Scaled Our Retail Operations With Cloud and App Platforms During the Lockdown</a> was originally published in <a href="https://medium.com/firebase-developers">Firebase Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test React Hooks in React Native (Expo.js) with react-native-testing-library]]></title>
            <link>https://medium.com/@goodpic/test-react-hooks-in-react-native-expo-js-with-react-native-testing-library-f77ec2678334?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f77ec2678334</guid>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-testing-library]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Thu, 12 Sep 2019 17:15:46 GMT</pubDate>
            <atom:updated>2019-09-12T17:27:19.706Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://reactjs.org/docs/hooks-intro.html">React Hooks</a> is fun, and once start using it, I needed to slightly change my mind how to structure and test the components, comparing to the class-based components.</p><p>For example, <a href="https://medium.com/@goodpic/testing-react-native-app-with-react-test-renderer-typescript-and-hoc-702a8fdb86df">I tended to test the instance of the class-based component</a> while changing the state manually, using <a href="https://reactjs.org/docs/test-renderer.html">react-test-renderer</a>. But obviously, the function-component would not have the instance, and it is more proper to simulate how the user uses the application rather than tweaking the internal state.</p><p>I tried several testing frameworks and <a href="https://github.com/callstack/react-native-testing-library">react-native-testing-library</a> works quite smoothly with Expo.js (React Native) + TypeScript + Jest. It is based on react-test-renderer and aimed to replace Enzyme.</p><p>Here is my example to test the state change using React Hooks.</p><h3>Function component using Hooks + TypeScript</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a359afd6fa345fcecadd8167fd5d031/href">https://medium.com/media/6a359afd6fa345fcecadd8167fd5d031/href</a></iframe><h3>Test with react-native-test-library + Jest</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd8716b7ec9185523ecff6f24c62d44c/href">https://medium.com/media/bd8716b7ec9185523ecff6f24c62d44c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f77ec2678334" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraphQL Client for Firebase Cloud Functions]]></title>
            <link>https://medium.com/@goodpic/graphql-client-for-firebase-cloud-functions-da36c21e7594?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/da36c21e7594</guid>
            <category><![CDATA[cloud-functions]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[apollo-client]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Fri, 17 May 2019 23:42:23 GMT</pubDate>
            <atom:updated>2019-05-22T09:44:26.615Z</atom:updated>
            <content:encoded><![CDATA[<p>I have been using <a href="https://github.com/apollographql/apollo-client">Apollo Client</a> to connect to the GraphQL server from my Expo (React Native ) app. But eventually, the GraphQL queries became messy, especially with the local state/cache management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xi51tqfIs1kGbSwChS-cLQ.png" /></figure><p>So I decided to move the GraphQL client from the app to the Firebase cloud functions. The app triggers the cloud function which fetches the data from GraphQL server to store it into FireStore. The app can observe the FireStore with onSnapshot() and receive the real-time update.</p><p>It always takes some time to set up anew application environment and indeed I encountered several issues when configuring the Firebase Cloud Functions.</p><p>Here is my boilerplate to get started</p><ul><li><a href="https://github.com/goodpic/firebase-graphql-boilerplate">https://github.com/goodpic/firebase-graphql-boilerplate</a></li></ul><p>with the following libraries.</p><ul><li>Cloud Functions for Firebase</li><li>TypeScript</li><li>Apollo Client</li><li>Jest</li></ul><h3>node-fetch with apollo-link-http</h3><p>One of the issues was “fetch” in apollo-link-http. The HTTP Link relies on having fetch present in the runtime environment, and <a href="https://www.apollographql.com/docs/link/links/http#fetch">the documentation recommends</a> node-fetch for Node.</p><p>For example to connect to the <a href="https://graphcms.com/blog/the-star-wars-api-just-got-a-makeover/">Star Wars GraphQL API</a>.</p><pre>import fetch from &#39;node-fetch&#39;<br>import { createHttpLink } from &#39;apollo-link-http&#39;<br>import { InMemoryCache } from &#39;apollo-cache-inmemory&#39;<br>import ApolloClient from &#39;apollo-client&#39;<br>import gql from &#39;graphql-tag&#39;</pre><pre>const GraphqlClient = () =&gt; {</pre><pre>return {<br>  exec: async () =&gt; {<br>    const client = new ApolloClient({<br>      link: createHttpLink({<br>        fetch: fetch,<br>        uri: &quot;<a href="https://api.graphcms.com/simple/v1/swapi">https://api.graphcms.com/simple/v1/swapi</a> &quot;,<br>      }),<br>      cache: new InMemoryCache(),<br>    })</pre><pre>    let films = null<br>    try {<br>      const result =  await client.query({<br>        query: gql`<br>        query {<br>          allFilms {<br>            title<br>          }<br>        }`<br>      })<br>      films = result.data<br>    }<br>    catch (error) {<br>      console.log(error);<br>    }<br>    return films<br>    },<br>  }<br>}</pre><pre>export default GraphqlClient</pre><p>But TypeScript shows the type incompatible error with this. There is <a href="https://github.com/apollographql/apollo-link/issues/513">a long conversation</a> on the apollo-link repo and several solutions are suggested in there.</p><p>The one works for me was:</p><ul><li><strong>NOT using</strong> @types/node-fetch (uninstall if already installed)</li><li>but to add the following declaration in the type declaration file.</li></ul><pre>declare module &#39;node-fetch&#39; {<br>  const fetch: GlobalFetch[&#39;fetch&#39;];<br>  export default fetch;<br>}</pre><p>I am not sure whether this is the best solution or not, but none of the other solutions worked for me unfortunatelly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da36c21e7594" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing React Native app with React Test Renderer, TypeScript and HOC]]></title>
            <link>https://medium.com/@goodpic/testing-react-native-app-with-react-test-renderer-typescript-and-hoc-702a8fdb86df?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/702a8fdb86df</guid>
            <category><![CDATA[react-test-renderer]]></category>
            <category><![CDATA[học]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-testing-library]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Wed, 10 Apr 2019 22:38:21 GMT</pubDate>
            <atom:updated>2019-04-10T22:38:21.404Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://docs.expo.io/versions/v32.0.0/guides/testing-with-jest/">Expo.js’ Jest introduction document</a> is useful to start the unit testing of the Expo app. But soon I was lost in <a href="https://codeburst.io/revisiting-react-testing-in-2019-ee72bb5346f4">the deep forest of the various testing libraries</a> for React.</p><p><a href="https://reactjs.org/docs/test-renderer.html">react-test-renderer</a> seems to be promising, but the documentation is a kind of bare minimum. TypeScript examples were also fewer than the web. So here is my note, hoping to help someone like me.</p><p><em>The full example is at the bottom of this article.</em></p><h3>Simple React Component to test</h3><p>Let’s consider to test this simple react component.</p><pre>import * as React from &#39;react&#39;;<br>import { Component } from &#39;react&#39;;<br>import { Text } from &#39;react-native&#39;;</pre><pre>interface IProps {<br>  count?: number;<br>}<br>interface IState {<br>  count: number;<br>}</pre><pre>class TestClass extends Component&lt;IProps, IState&gt;  {</pre><pre>state: IState = {<br>    count: this.props.count || 0,<br>  };</pre><pre>render() {<br>    return(&lt;Text testID=&#39;counter&#39;&gt;{this.state.count}&lt;/Text&gt;);<br>  }<br>}</pre><pre>export default TestClass;</pre><p>The first test case to check the initial state look like this.</p><pre>it(&quot;should have counter element&quot;, () =&gt; {<br>  let root = renderer.root;<br>  const counter = root.findAll(<br>    (el) =&gt; el.props.testID === &#39;counter&#39;<br>  );<br>  expect(counter).toHaveLength(1);<br>});</pre><h3>TypeError: Cannot read property ‘createElement’ of undefined</h3><p>The first time I run the test, I got into “TypeError: Cannot read property ‘createElement’ of undefined” error. It was because of this React import statement.</p><pre>import React, { Component } from &#39;react&#39;;</pre><p>With TypeScript, it should be:</p><pre>import * as React from &#39;react&#39;;<br>import { Component } from &#39;react&#39;;</pre><h3>Duplicated length when findAll()</h3><p>Then when I tried to find the element by testID, the length was 2 instead of 1 even the dumped JSON shows only one element.</p><pre>it(&quot;should have one counter element&quot;, () =&gt; {<br>  let root = renderer.root;<br>  const tree = renderer.toJSON();<br>  console.log(tree)<br>  const counter = root.findAll(<br>    (el) =&gt; el.props.testID === &#39;counter&#39;<br>  );<br>  expect(counter).toHaveLength(1);<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gW1T6TTSiIU5v51GOhpPMA.png" /></figure><p>After googling around, I found that <a href="https://github.com/facebook/react-native/issues/16281#issuecomment-414091697">the parent Component also would have the same testID so the component type had to be specified</a> at the same time.</p><pre>el.props.testID === &#39;counter&#39; &amp;&amp; el.type === &#39;Text&#39;</pre><h3>instance.setState() to test the state change</h3><p>How about checking the state change? I thought that should relate to .getInstance() in the documentation, but actually, I could get the instance directory from the root element.</p><pre>it(&quot;should setState the counter to 1&quot;, () =&gt; {<br>  let root = renderer.root;<br>  const instance = root.instance;<br>  instance.setState({ count: 1 })<br>  const counter = root.findAll(<br>    (el) =&gt; el.props.testID === &#39;counter&#39; &amp;&amp; el.type === &#39;Text&#39;<br>  );<br>  expect(counter[0].children).toEqual([&#39;1&#39;]);<br>});</pre><h3>Test HOC (Higher-Order Components)</h3><p>Finally, the test for Higher Order Components. Just imagine a HOC which gets some parameters and do something to pass down the processed props to the wrapped component. This is a useless HOC example but just to see how to test it.</p><pre>import * as React from &#39;react&#39;;<br>import { Component } from &#39;react&#39;;</pre><pre>interface IProps {}<br>interface IState {}</pre><pre>function TestHoc(params: any) {<br>  return (WrappedComponent: any) =&gt; {</pre><pre>    return class CountFactory extends Component&lt;IProps, IState&gt; {</pre><pre>      render() {<br>        return (&lt;WrappedComponent {...params} /&gt;);<br>      }<br>    }<br>  }<br>}</pre><pre>export default TestHoc;</pre><p>All you need to do is to compose the HOC before TestRenderer.create.</p><pre>describe(&#39;Set preps With HOC&#39;, () =&gt; {</pre><pre>  it(&quot;should preset counter to 2&quot;, () =&gt; {<br>    const CountFactory = TestHoc({ count: 2 })(TestClass);  <br>    renderer = TestRenderer.create(<br>      &lt;CountFactory /&gt;<br>    );</pre><pre>    let root = renderer.root;<br>    const counter = root.findAll(<br>      (el) =&gt; el.props.testID === &#39;counter&#39; &amp;&amp; el.type === &#39;Text&#39;<br>    );<br>    expect(counter[0].children).toEqual([&#39;2&#39;]);<br>  });<br>  <br>});</pre><h3>Conclusion</h3><p>The final shape of the unit test would like as below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb8978732560b04e72af93e892eae182/href">https://medium.com/media/bb8978732560b04e72af93e892eae182/href</a></iframe><p>These look quite obvious once they’ve been written but it just took a bit of time to search around the various documents and tips.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=702a8fdb86df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Expo Barcode Scanner with React-Navigation]]></title>
            <link>https://medium.com/@goodpic/expo-barcode-scanner-with-react-navigation-aafc2556e6f3?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/aafc2556e6f3</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-navigation]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[barcode]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Fri, 04 Jan 2019 23:49:53 GMT</pubDate>
            <atom:updated>2019-01-04T23:49:53.642Z</atom:updated>
            <content:encoded><![CDATA[<p>Tips to use React Native <a href="https://docs.expo.io/versions/latest/sdk/bar-code-scanner">Expo Barcode Scanner</a> with <a href="https://reactnavigation.org/">React Navigation</a>. When using the expo barcode reader in one of the BottomTabNavigator tabs, use <a href="https://reactnavigation.org/docs/en/navigation-prop.html#addlistener-subscribe-to-updates-to-navigation-lifecycle">navigation.addListener</a> to stop/resume the scanning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*kvuvqm4mXKUBGRp-MXNuvw.jpeg" /><figcaption>Expo Barcode Scanner</figcaption></figure><h3>Expo Barcode Scanner Component</h3><p>Here is the sample component to use Barcode Reader on React Native Expo.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4341d6505c0037185ccc3d94d0371955/href">https://medium.com/media/4341d6505c0037185ccc3d94d0371955/href</a></iframe><h3>Pause and resume scanning on Scanner Screen</h3><p>When using the scanner component on one of the tabs managed by BottomTabNavigator, the scan should be paused when navigating to the other screens. You can use <a href="https://reactnavigation.org/docs/en/navigation-prop.html#addlistener-subscribe-to-updates-to-navigation-lifecycle">React Navigation emits events “didFocus” and “willBlur”</a> to pause/resume the component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba78321f486a19cfb47d0da952ad767e/href">https://medium.com/media/ba78321f486a19cfb47d0da952ad767e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aafc2556e6f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrate Google Spreadsheet with Big Query by Apps Script]]></title>
            <link>https://medium.com/@goodpic/integrate-google-spreadsheet-with-big-query-by-apps-script-d9c7574af64?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9c7574af64</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[google-sheets]]></category>
            <category><![CDATA[google-spreadsheets]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[google-apps-script]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Wed, 21 Nov 2018 08:29:47 GMT</pubDate>
            <atom:updated>2018-11-21T08:29:47.968Z</atom:updated>
            <content:encoded><![CDATA[<p>Google Data Studio is a good option to visualise the Big Query data. But Google SpreadSheet sometimes works better especially when you handle a lot of data columns.</p><p>You may want to share one Google spreadsheet with colleagues with the designed formulas and keep updating it with the latest data on Big Query.<br>Here is how to integrate the BigQuery into Google Sheet by using the Google Apps Script.</p><h3>Save the complex query as a view on Big Query</h3><p>An analytic SQL query could be quite long if you join and process multiple tables, and it is better to manage it on BigQuery instead of embedding the SQL in the Apps Script. You can save your query as a “View” on Big Query’s query editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*1GXpYYM2iNhD6TtVNV21KA.png" /></figure><p>For example, if you save the complex query as “table_name,” it can be simply queried as:</p><p>SELECT * FROM project_name.dataset_name.table_name;</p><h3>Overwrite the data rows on the Google sheet</h3><p>When dealing Big Query data on Google Sheet, you need to use multiple sheets (tabs) on one spreadsheet, one for the data source and others for the presentation.</p><p>For example, if you have the “latest” sheet as the data source, you could <a href="https://support.google.com/docs/answer/3093343?hl=en">QUERY</a> the data from the other sheets to present the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MkgQnyEBl6Mp696cWrvzHw.png" /></figure><p>Then you can overwrite the whole data in the datasheet pulling from Big Query. To trigger the query, we are going to add a custom menu to the spreadsheet.</p><h3>Google Apps Script to Integrate Big Query into Google Sheet</h3><p>Here is the Google Apps Script to add your custom menu to the Google Sheet. To add this script to your google sheet:</p><ol><li>Select “Tools” &gt; “Script Editors” on the spreadsheet menu.</li><li>Paste the following code to the script editor.</li><li>Change YOUR_PROJECT_ID, YOUR_DATA_SOURCE_SHEET_NAME and YOUR_PROJECT_NAME.DATASET_NAME.TABLE_NAME in the script.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a9fa30095c61c12132b34ec8070e8e5/href">https://medium.com/media/2a9fa30095c61c12132b34ec8070e8e5/href</a></iframe><p>Then edit a manifest.js by</p><ol><li>On the Script Editor, “View” &gt; “Show manifest file”</li><li>Edit and save as follows:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36fe12cf6487be9ff36f662f27eb5d3c/href">https://medium.com/media/36fe12cf6487be9ff36f662f27eb5d3c/href</a></iframe><p>Once done, save the script and reload the spreadsheet, then you will see the “BigQuery” menu in the navigation.</p><p>When you select the “Update data”, the Google sheet will fetch the query to BigQuery and replace the data source sheet with the latest data from Big Query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lE-F87NHLGyUhbwTjlD12g.png" /></figure><p>When you first select the menu, it will request the permissions on this sheet and it may also show “Access Not Configured. BigQuery API has not been used in project XXXX” error. In that case, click “Details” in the error message, and follow the link in the error message to enable the Big Query for the Apps Script. The user also needs to have the “BigQuery Data Viewer” and “BigQuery Job User” permissions which you can add at Google Cloud “IAM and admin” screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*7M36GEshB39F9jMTMBXUjg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9c7574af64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BigQuery: Create and delete a table from the Node client]]></title>
            <link>https://medium.com/@goodpic/bigquery-create-and-delete-a-table-from-the-node-client-738015b67d4a?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/738015b67d4a</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[commanderjs]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Sat, 15 Sep 2018 22:19:02 GMT</pubDate>
            <atom:updated>2018-09-15T22:19:02.717Z</atom:updated>
            <content:encoded><![CDATA[<p>Next, We would like to save <a href="https://medium.com/@goodpic/bigquery-at-retail-create-an-hourly-sales-summary-from-the-raw-sales-data-72070c1a008a">the hourly sales summary created in the previous post</a> in BigQuery.</p><h3>BigQuery Node.js client library</h3><p>When playing with the sales data and the dashboard, I often need to update or modify the database schema to add the various analytic views. It would be much easier to operate the BigQuery from the Node.js client rather than working manually on the admin page. The client script could be used as the automated script as well to update the data periodically.</p><p>There is <a href="https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-install-nodejs">a good installation guide</a> to set up the Node BigQuery client. The <a href="https://github.com/tj/commander.js/">Commander.js</a> library is also useful to develop your own BigQuery command line tools.</p><h3>Create and delete a table from the Node client</h3><p>Here is the example of creating and dropping a table from the BigQuery Node.js client. Save it as “/src/bigquery.js”</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8bc5f7d930eeb67e8bd94fedc4d1b1f/href">https://medium.com/media/b8bc5f7d930eeb67e8bd94fedc4d1b1f/href</a></iframe><h3>Define the schema for the hourly sales summary</h3><p>Save the following schema as “/schemas/SchemaSalesByHour.js”</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad22ce3946102a316baede473c7dc401/href">https://medium.com/media/ad22ce3946102a316baede473c7dc401/href</a></iframe><h3>Command to create a new table</h3><p>Then create the following commander script to require the library and schema files, saved it as “./command/create.js”</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8292fed62117a6c8f1b366b541dbc65d/href">https://medium.com/media/8292fed62117a6c8f1b366b541dbc65d/href</a></iframe><p>To create the table, type the following command on the terminal.</p><blockquote>% node ./commands/create.js -t shop_sales_by_hour</blockquote><h3>Command to drop the table</h3><p>Saved the command as “./command/drop.js”</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3387c5bcff81404c094eecbc2e75488f/href">https://medium.com/media/3387c5bcff81404c094eecbc2e75488f/href</a></iframe><p>To delete the table, type the following command on the terminal.</p><blockquote>% node ./commands/drop.js -t shop_sales_by_hour</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=738015b67d4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BigQuery at Retail: Create an hourly sales summary from the raw sales data]]></title>
            <link>https://medium.com/@goodpic/bigquery-at-retail-create-an-hourly-sales-summary-from-the-raw-sales-data-72070c1a008a?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/72070c1a008a</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[retail-technology]]></category>
            <category><![CDATA[bigquery]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Mon, 10 Sep 2018 23:55:17 GMT</pubDate>
            <atom:updated>2018-09-15T22:20:17.401Z</atom:updated>
            <content:encoded><![CDATA[<p>I want to share some of my learning while implementing the data dashboard for a retail business using Google BigQuery and Data Studio.</p><p>Let’s assume that we have a set of following sales data.</p><ul><li>transactions</li><li>transaction_items</li></ul><p>The “transactions” table stores individual purchase transactions from customers, and the “transaction_items” table stores individual items in the transactions.</p><p>For example, when you buy the following items at the store, each of these items will be recorded as an entry in the “transaction_items” table.</p><ul><li>Two bottles of water (£1 x 2 qty)</li><li>One pack of crisps (£1.5 x 1 qty)</li></ul><p>and the total sales of £3.5 would be recorded as an entry of the “transactions” table.</p><p>I pulled these sales data from the Point Of Sales (EPOS / Till) system and set to sync with Google BigQuery periodically.</p><h3>Big Query Schema for the transactions</h3><p>Here is the example schema of the “transactions” table.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09684f89f2feb65c367681dbd19954fe/href">https://medium.com/media/09684f89f2feb65c367681dbd19954fe/href</a></iframe><p>and “transaction_items” table.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78b7c4aec82c774169cb0ff6c741db2a/href">https://medium.com/media/78b7c4aec82c774169cb0ff6c741db2a/href</a></iframe><p>You may have realised that these two tables are denormalised, for example, “shop_name” and “invoiced_at” columns exist in both tables. It is <a href="https://cloud.google.com/bigquery/preparing-data-for-loading#loading_denormalized_data">actually recommended</a> to make BigQuery <a href="https://cloud.google.com/solutions/bigquery-data-warehouse#denormalizing_data">perform better</a>.</p><p>Although BigQuery charges you with the size of data you query, you would not be penalised by the redundant columns as long as you select only the specific columns you need in the query.</p><h3>Summarise the sales transactions</h3><p>Uploading loads of data to BigQuery is a pain. But once you have done, it is amazingly easy and fast to run the query <a href="https://cloud.google.com/blog/products/gcp/bigquery-under-the-hood">on the powerful Google data centre</a>.</p><p>Let’s start by summarising all the transactions into hourly sales figures. BigQuery provides <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators">various SQL functions</a> to compile the data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1940a846254c727d41b74127731973a/href">https://medium.com/media/b1940a846254c727d41b74127731973a/href</a></iframe><p>Here, we use:</p><ul><li><a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#datetime_trunc">DATETIME_TRUNC</a> and <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#timestamp_trunc">TIMESTAMP_TRUNC</a> to truncate the time of the transactions and group into hourly figures.</li><li><a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#format_datetime">FORMAT_DATETIME</a> to store the day of the transactions in a human-readable format.</li><li>The reason for MOD() the day number is to <a href="https://www.en.advertisercommunity.com/t5/Data-Studio/Bug-Day-of-Week-Pie-chart/td-p/1589792#">bridge the difference between how BigQuery and DataStudio handle the numbers of the days in a week</a>.</li></ul><p>Continue to “<a href="https://medium.com/@goodpic/bigquery-create-and-delete-a-table-from-the-node-client-738015b67d4a">Create and delete a table from the Node client</a>”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72070c1a008a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RNCamera as a free barcode scanner lib for React Native]]></title>
            <link>https://medium.com/@goodpic/rncamera-as-a-free-barcode-scanner-lib-for-react-native-110fa0c610af?source=rss-9a145dd5d7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/110fa0c610af</guid>
            <category><![CDATA[barcode-scanner]]></category>
            <category><![CDATA[rncamera]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[barcode]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jun Kaneko]]></dc:creator>
            <pubDate>Fri, 08 Jun 2018 09:51:25 GMT</pubDate>
            <atom:updated>2019-01-05T00:09:31.653Z</atom:updated>
            <content:encoded><![CDATA[<p>I was looking for a barcode scanner library for React Native. RNCamera (<a href="https://github.com/react-native-community/react-native-camera/">react-native-camera</a>) is a free (MIT license) camera library which has a barcode scanning capability as well.</p><p>Here is the working example component to use the RNCamera as a barcode reader. It works fine and probably good for the basic use-case for the free consumer apps.</p><p>If you are using Expo, <a href="https://medium.com/@goodpic/expo-barcode-scanner-with-react-navigation-aafc2556e6f3">the other sample with React Navigation is on this page</a>.</p><h3>Install RNCamera to your React Native project</h3><p>Read <a href="https://www.npmjs.com/package/react-native-camera">the installation guide</a>. There are several configurations after the npm install as follows.</p><ol><li>$ npm install react-native-camera --save</li><li>$ react-native link react-native-camera</li></ol><p>But I run into the error “<strong>Cannot read property ‘Aspect’ of undefined</strong>” which basically means that the RNCamera module has not been installed correctly. For my case, “react-native link” did not copy the required file and I had to <a href="https://github.com/react-native-community/react-native-camera/issues/786#issuecomment-370882978">do it manually as described here</a>.</p><h3>Sample code to use RNCamera as a barcode reader</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45df34f85a50b75b45d2cc9cf298aba5/href">https://medium.com/media/45df34f85a50b75b45d2cc9cf298aba5/href</a></iframe><p>I will write about Scandit in the next post which I am using for the development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=110fa0c610af" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>