<?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 zetta on Medium]]></title>
        <description><![CDATA[Stories by zetta on Medium]]></description>
        <link>https://medium.com/@locropulenton?source=rss-52211b671242------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tznQJvDnmYfArpNvNxhxfA.png</url>
            <title>Stories by zetta on Medium</title>
            <link>https://medium.com/@locropulenton?source=rss-52211b671242------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:51:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@locropulenton/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[Bringing the blockchain to React Native]]></title>
            <link>https://medium.com/hackernoon/bringing-the-blockchain-to-react-native-98b76e15d44d?source=rss-52211b671242------2</link>
            <guid isPermaLink="false">https://medium.com/p/98b76e15d44d</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native-blockchain]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[zetta]]></dc:creator>
            <pubDate>Wed, 07 Feb 2018 13:06:02 GMT</pubDate>
            <atom:updated>2018-02-07T17:02:02.004Z</atom:updated>
            <content:encoded><![CDATA[<p><em>TLDR: Despite the fact of the non existence of an Ethereum Wallet or Browser for React Native to interact with cross platform decentralized mobile apps, it’s possible bring the blockchain to React Native.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VSfBoCNkjpEIM_NUzVzOcQ.jpeg" /><figcaption>Bringing blockchain to cross platform apps by React Native. Credits to pixabay.</figcaption></figure><p>According to the <a href="https://github.com/DavidJohnstonCEO/DecentralizedApplications">dApp’s white paper</a> basically a <strong>dApp</strong> has its backend code running on a decentralized peer-to-peer network. Contrast this with an app in which the backend code is running on centralized servers.</p><p>The transparent immutable and decentralized nature of the blockchain enables the development of many awesome use cases such as for autonomous organization, sales, social networks, insurance companies and gaming among hundreds of others.</p><h3>Joseph Lubin on Twitter</h3><p>To _really_ make it permanent, Dr. @ChrisLundkvist can perform ceremony &amp;amp; memorialize union on blockchain. :-) https://t.co/lPY8YiPTRP</p><p>In this blog post I will explain how I made a mobile cross platform dApp aimed at ranking your favorites <a href="https://www.larvalabs.com/cryptopunks">cryptopunks</a> using React Native.</p><h3>I zetta on Twitter</h3><p>This alien is stored in the ethereum blockchain. Its value is 12Ξ ($15,733.92). #cryptopunks #cryptocurrency This alien is now stored in this tweet, how much is this tweet? I think I don&#39;t get it pretty well. https://t.co/JHYhKYaEEL</p><p>wait… <strong>why cryptopunks? </strong>cryptopunks is an awesome project that works just like a metaphore, for more info look into the following <a href="https://www.reddit.com/r/ethtrader/comments/7hdycd/if_you_think_cryptokitties_is_about_cats_youre/">blog post in reddit</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n1JgrR9xzw5zkR6suqK3JA.png" /><figcaption>Credits <a href="https://blockgeeks.com/guides/initial-coin-offering/">https://blockgeeks.com/</a></figcaption></figure><h3>The Stack</h3><p>Before we get to code, it is important to understand how to break this down.</p><ul><li><a href="https://facebook.github.io/react-native/">React Native</a> is a framework developed by Facebook that allows you to build native cross platform mobile apps using JavaScript and React.</li><li><a href="http://expo.io/">Expo</a> is a set of tools that makes it significantly easier to get started with <strong>React Native</strong> projects, since it includes a set of native APIs to be used right out of the box, like camera, etc.</li><li><a href="https://github.com/ethereum/web3.js/">Web3</a> is the Ethereum compatible <a href="https://github.com/ethereum/wiki/wiki/JavaScript-API">JavaScript API</a> which implements the <a href="https://github.com/ethereum/wiki/wiki/JSON-RPC">Generic JSON RPC</a> spec built for node.js and the browser.</li><li><a href="https://github.com/trufflesuite">Truffle</a> is a development environment for Ethereum, that provides a set of tools like <a href="https://github.com/trufflesuite/ganache-core">ganache-core</a> that simulates an Ethereum network in the localhost which is great for getting started.</li><li>Among other cool libraries worth mentioning like <em>react-navigation,</em> <em>victory-native and react-native-star-rating.</em></li></ul><h3>The Ethereum blockchain on React Native</h3><p>There are many <a href="https://github.com/ethereum/web3.js/issues/1022">open issues</a> about getting the <a href="https://github.com/ethereum/wiki/wiki/JavaScript-API">web3.js JavaScript API</a> to work on a React Native app, and it looks like there is not a <a href="https://github.com/concensus/react-native-ios-concensus/issues/3">real solution as of now</a>.</p><p>This is because React Native uses <a href="http://trac.webkit.org/wiki/JavaScriptCore">JavaScriptCore</a> execution environment, and depending on how the <a href="https://nodejs.org/api/index.html">Node standard library APIs</a> like buffer, <a href="https://nodejs.org/api/crypto.html">crypto</a> or stream are mocked or implemented for the React Native app, it might need to <a href="https://facebook.github.io/react-native/docs/linking-libraries-ios.html">link some native dependencies</a>; therefore, you may need to <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md">eject the expo app</a> as it is detailed in sample projects like <a href="https://github.com/philikon/ReactNativify">react-nativify</a> that brings the Node API to the React Native environment.</p><p>Thus, while I was looking into alternatives, and after finding <a href="https://expo.canny.io/feature-requests/p/crypto-api">the feature request on expo</a>, <strong>as a workaround </strong>I build a <a href="https://github.com/agrcrobles/babel-preset-react-native-web3">babel preset for react native</a> that behind scenes uses <a href="https://github.com/crypto-browserify/crypto-browserify">crypto-browserify</a> and a tiny pure javascript implementation of <a href="https://github.com/agrcrobles/babel-preset-react-native-web3/blob/master/src/randombytes.js">randombytes</a>.<br>But notice that JavaScript’s Math.random() function might be considered as a cryptographically predictable random number generator, but I don’t worry about it right now, since <a href="https://github.com/ethereumjs/ethereumjs-tx">ethereumjs-tx</a> doesn’t need it to sign transactions.</p><h3>So, aren’t voting transactions free?</h3><p>The short answer is no.<br>In <a href="https://etherscan.io/">mainnet</a> ( main Ethereum network ) all transactions are valued in real ethers or gas, but my experimental app is deployed on Testnet <a href="http://ropsten.etherscan.io/">Ropsten</a>, a real <em>staging</em> blockchain for developments purposes that allows only 5 votes / transactions per second, thanks goes to <a href="https://faucet.metamask.io/">faucet</a> for the free ethers to test it :)</p><p>In this simple implementation each Vote/Star is around <a href="https://ropsten.etherscan.io/tx/0xb9db465182b81240944d6800b1f1992503d2add9bd0d38f4236de4b0f83954f2"><em>0</em><strong><em>.</em></strong><em>0012 Ethers</em> (<em>USD 1.31</em> as of today)</a>. That is not cheap at all, but that fee might be improved if the gas consumed for each vote is decreased.<br>In that case the risk is that miners might take hours or days to process such low fee transactions.</p><p>There are ongoing discussions about how to improve this issue in the blockchain by using soft forks, LN, side chains or micro transactions.</p><h3>Armin van Bitcoin ⚡ on Twitter</h3><p>The number of lightning channels on mainnet surpasses 1,000! 🎉🥂👏 It&#39;s fast, it&#39;s anonymous, it&#39;s free and it&#39;s decentralized. #bitcoin #SegWit #LightningNetwork ⚡️🚀🌖 Nodes: 398 Channels: 1,000 Capacity: 4.04 BTC</p><h3>Sergio Demian Lerner on Twitter</h3><p>@locropulenton @peterktodd @delicopsch56 @Blockstream I think Bitcoin Lightning network, although complex, is a great system. Together with 3rd party payment channel insurance can help financial inclusion. I bet Lumino over RSK will work better, but LN is here, while Lumino is still being developed.</p><h3>Web3 Provider dilemma</h3><p>A transaction is a set of instructions for modifying the state of the blockchain In order to sign Ethereum transactions and consume gas, real ethers, a public address and a private key are needed, or an HD wallet configured with at least one unlocked coinbase account to pay for the <em>voting transaction</em>.</p><p>There are different ways of configuring the web3 provider to access dApps on the web either injected by an ethereum special browser like <a href="https://github.com/ethereum/mist">Mist</a>, through <a href="https://metamask.io/">MetaMask Chrome Extension</a> or by creating a local instance and configure an account with money right there on the code.</p><p>The thing is that there is no such browser for React Native and web3 cannot injected in the App, so in this experiment I ended up configuring the coinbase with <a href="http://truffle-hdwallet-provider/">truffle-hdwallet-provider</a>.</p><p>Another valid choice is the use of <a href="https://www.npmjs.com/package/web3-provider-engine">web3-provider-engine</a> from <a href="https://metamask.io/">MetaMask</a>, that allows you to sign transactions via a subprovider using <a href="https://gist.github.com/agrcrobles/d1cabde05fc38cc032336f1dbdbfb4df">pure javascript as I am detailing in this gist</a>, but there the situation is actually the same, since truffle-hdwallet-provider uses a similar mechanism behind scenes.</p><p>In both options mentioned, the account one way or another is coded in the mobile app, and that might be insecure in a real production environment and that lacks of flexibility.</p><p>Instead, a simple approach might be to ask the user the public and private key in order to sign the transaction and pay the vote, but that discarded since it is super insecure.</p><p>Or use <a href="https://www.uport.me/">uport</a> to register the identity of the voter, but I am still <a href="https://github.com/uport-project/uport-connect/issues/39">not sure about React Native support</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e52f35a033636be9bc7c643d5983fd8a/href">https://medium.com/media/e52f35a033636be9bc7c643d5983fd8a/href</a></iframe><p>I had seen the following project <a href="https://github.com/YsnKsy/react-native-geth">react-native-geth</a> that looks promising as a key dependency for a possible React Native HD wallet to inject web3 to any given App, since it implements a light client Ethereum node. Definitely ambitious.</p><h3>Smart Contracts</h3><p>I created a simple Voting contract in <a href="https://solidity.readthedocs.io/en/develop/">Solidity</a> language, and used <a href="https://github.com/trufflesuite/truffle-contract">truffle-contract</a> as an abstraction to consume it from the mobile dApp.</p><p>Contracts are also immutable. Once the contract is created and deployed on the blockchain, it cannot change, be undone or modified.</p><p>Voting has a constructor which initializes with an array of cryptopunks, and they are assigned with an identifier name based upon their primary accessories.</p><p>If you are curious about the contract, it is deployed on <a href="https://ropsten.etherscan.io/address/0x25cee65ac493a0c965f12a2d0c46fe82e09d6d44">Ropsten Testnet</a> network.<br>For more information about how I deployed it, see the following <a href="https://gist.github.com/agrcrobles/e03151b27ad4753827de227929677db3">gist</a>.</p><h3>Possible improvements</h3><ul><li>There are elections in which the more shares or token you own, the more votes you get. That can be reachable by providing a certain amount of ERC20 token to the voter.<br>That might not apply to cryptopunks, but is worth considering.</li></ul><h3>Demo</h3><ul><li><a href="https://expo.io/@agrcrobles/react-native-blockchain-poll">react-native-blockchain-poll on Expo</a></li><li><a href="https://github.com/agrcrobles/react-native-blockchain-poll">agrcrobles/react-native-blockchain-poll</a></li></ul><h3>Thoughts</h3><p>Despite the amount of use-cases the blockchain brings, as of today, it is not being adopted by big companies on mobile apps that often; since all ICOs, instead, are web-based.</p><p>People from <a href="https://www.cipherbrowser.com/">cipherbrowser</a> and <a href="https://status.im/">status.im</a> are making an awesome job creating mobile dApp browsers, I think that step have just been done.</p><p>I am supportive of the idea of decentralized cross platform mobile apps, React Native is getting mature and more stable as time passes by, and it’s been adopted by big companies to develop really great mobile apps ( in fact status.im mobile app is built on React Native ), and I am pretty sure that the use of the blockchain in React Native to build real mobile dApps is just around the corner.</p><p>Opinions are my own, and I might be wrong. Thanks for reading.</p><h3>Credits</h3><p>Credits to the awesome <a href="https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2">Medium article</a> by Mahesh Murthy that walked me through the creation a Voting simple smart contract.</p><p>Credits to open source projects like <a href="https://github.com/concensus/react-native-ios-concensus/">react-native-ios-concensus</a>, <a href="https://github.com/bullish-ventures/react-native-web3-example">react-native-web3-example</a> or <a href="https://github.com/truffle-box/react-native-box">react-native-box</a>, that aims at a similar goal with a different approach.</p><p>Thanks to my sister and <a href="https://twitter.com/Pitorrr">@pittorrr</a> who helped me with the write up, and <a href="https://www.instagram.com/gisela.d.muro/">@gisela.d.muro</a> as usual to encourage me to write the article.</p><h3>References</h3><ul><li><a href="https://ethereum.stackexchange.com/questions/383/what-is-a-dapp">https://ethereum.stackexchange.com/questions/383/what-is-a-dapp</a></li><li><a href="https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369">https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369</a></li><li><a href="https://medium.com/@jgm.orinoco/understanding-erc-20-token-contracts-a809a7310aa5">https://medium.com/@jgm.orinoco/understanding-erc-20-token-contracts-a809a7310aa5</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98b76e15d44d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/bringing-the-blockchain-to-react-native-98b76e15d44d">Bringing the blockchain to React Native</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An augmented reality experiment in React Native]]></title>
            <link>https://medium.com/hello-js/an-augmented-reality-experiment-in-react-native-fc473f6c1b5c?source=rss-52211b671242------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc473f6c1b5c</guid>
            <category><![CDATA[experiment]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[zetta]]></dc:creator>
            <pubDate>Thu, 13 Jul 2017 22:59:55 GMT</pubDate>
            <atom:updated>2017-07-18T08:10:05.710Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>tldr; </em></strong><em>if you want to see how a simple augmented reality app is developed, see the </em><a href="https://github.com/agrcrobles/react-native-live-translator"><em>following repository</em></a><em>.</em></p><p>Sometimes the source code behind an idea is complicated, but this time is not the case.</p><p>Augmented reality is an overlay of content on the real world, its purpose it to enhance the existing reality in order to make it more meaningful somehow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jz9SrVNsePaOwMHEqHseZw.jpeg" /><figcaption>How will you add any experience that adds value to any moment in life without missing the moment itself?</figcaption></figure><p>With that in mind, I’ve built a small app as an experiment that translates and subtitles in real time what you see from the camera your phone.</p><p>With the help of advanced Google Cloud technology such as <a href="https://cloud.google.com/vision/">Cloud Vision</a>, the information and the surrounding environment can become interactive.</p><p>I am aware that there are others open source alternatives like <a href="http://opencv.org/">Open Cloud Vision</a>, but I am happy to choose Google Cloud API for doing this app demo since I found its implementation is encouraging.<br>I am also aware it is not free at all, but I still have a trial time to play with it and make this experiment real.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*XWclOb-wqb_RNQFSU-qLSw.png" /><figcaption>Google Cloud API dashboard</figcaption></figure><h3>Behind the scenes</h3><p><a href="https://facebook.github.io/react-native/docs/textinput.html">ReactNative</a> is a framework used to build native mobile apps using JavaScript and React.</p><p>In React, <a href="https://github.com/facebook/react-vr">virtual reality</a> is considered as a new platform, as Android or the web, which is great in terms of consistency and scalability, but mobile integration is not out of the box as of <strong>today.</strong></p><p>In short, behind the scenes the app, using the camera captures and extracts the text with support for a broad range of languages for any given scenario. It also features automatic language identification.</p><p>The API provides a result to be sent to the <a href="https://cloud.google.com/translate/docs/?hl=es-419">Translate API</a> in order to display the response text in a layer on top of the camera video as a subtitle.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9fcfa1e304b555dc6c1b1fa1b0b279d/href">https://medium.com/media/b9fcfa1e304b555dc6c1b1fa1b0b279d/href</a></iframe><p><strong>Animations: </strong>I am using the accelerometer to create an animated transition in order to create an experience when rotating the mobile on the z axis.</p><p>For more information about that, look into the following <strong>snacks</strong> about how I <a href="https://snack.expo.io/B1jDvJEH-">made a z axis transformation</a> and a <a href="https://snack.expo.io/SkhJOy4B-">simple toggle selector</a>.</p><p><strong>Performance: </strong>Looking into the performance monitor I found that I am not achieving <em>60 frames per second</em> but dropping some frames, basically because I am doing a lot of things in the UI threat at the same time. The camera is capturing each n millisecond and the transformation applied <a href="https://github.com/facebook/react-native/issues/13150">cannot be used by the native driver</a>.<br>User experience is good enough for now, but I am aware it could be improved in the future.</p><h3>Possible improvements</h3><p>Though this app has been developed as a prototype there are many improvements that could be also considered in the future.</p><p><a href="https://www.npmjs.com/package/compute-hamming">Compute hamming</a>: Computes the <a href="http://en.wikipedia.org/wiki/Hamming_distance">Hamming distance</a> between two sequences, that could be useful to identify and verify that the translated text has changed enough to be re calculated.</p><p>An <a href="https://github.com/cezary/react-image-diff">image diff</a> algorithm could be also useful to avoid overkill when taking a photo.</p><p>As well as the usage of the <a href="https://github.com/GoogleCloudPlatform/google-cloud-node">API library for Node.js</a> for Google Cloud, to improve the error handler, code style and encoding.</p><h3>Launched just for beta testers</h3><figure><a href="https://play.google.com/apps/testing/com.livetranslator"><img alt="" src="https://cdn-images-1.medium.com/max/200/1*hnnJtC4LnfZSrEKuZ44MNw.png" /></a></figure><p>Yay! after adding 40 seconds of timeout and some integrations for the Android platform such as <a href="https://microsoft.github.io/code-push/">code push</a> and crash reporting, I released a simple version for beta testers in the <a href="https://play.google.com/apps/testing/com.livetranslator">Google Store</a> so that users can play with it a little bit.</p><h3>More use cases</h3><p>There are other use cases where it can be improved and enhanced. Imagine you go to a restaurant in a foreign country for dinner and you can’t understand the menu.</p><p>Or if you travel abroad to Barcelona or Buenos Aires, can it make you easier to understand where are you going in the metro or in a bus when looking at the signs?</p><p>There are “infinite” use cases here for different places or situations as of where this sample could be improved to become a real application that adds value somewhere and someplace.</p><p>In fact, a great augmented reality app has been just released, and helps blind people to recognize objects, that is amazing!</p><h3>FieldHouse on Twitter</h3><p>An incredible app helps the visually impaired identify what&#39;s around them. #Tech #Innovation @aipoly https://t.co/A94Ol7gmmS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*G5wOCOeIVAaKGCgC7KHjjQ.gif" /></figure><h3>Disclaimer</h3><p>This has been done as an experiment and not for commercial purposes.</p><h3>Source Code</h3><p>For obvious reasons I am not sharing the Google Cloud License Key, I encourage you to try it, play it yourself and contribute, create a Google Cloud account and made it work!</p><p>I am not using <a href="https://threejs.org/">Three.js</a> because it is not supported for the mobile platform out of the box, just <a href="https://facebook.github.io/react-native/docs/animated.html">Animated.js</a> from Facebook to perform the animations detailed above.</p><p>For more information about that, have a look into the following <a href="https://github.com/agrcrobles/react-native-live-translator">repository</a>.</p><h3>License is MIT.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc473f6c1b5c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hello-js/an-augmented-reality-experiment-in-react-native-fc473f6c1b5c">An augmented reality experiment in React Native</a> was originally published in <a href="https://medium.com/hello-js">hello JS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A cross platform app with React in a monorepo]]></title>
            <link>https://medium.com/hello-js/a-cross-platform-app-with-react-in-a-monorepo-9c6aa6aed818?source=rss-52211b671242------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c6aa6aed818</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[monorepo]]></category>
            <dc:creator><![CDATA[zetta]]></dc:creator>
            <pubDate>Mon, 22 May 2017 07:05:36 GMT</pubDate>
            <atom:updated>2017-07-23T09:30:59.322Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WFuLcWe3_zRV_85hvy7vmQ.jpeg" /><figcaption>joining the pieces of code…</figcaption></figure><p><strong><em>tldr; </em></strong><em>a cross platform mobile and web app should be developed in a monorepo, and you should plug the app into the base code and not on the other way around.</em></p><p>In this blog post I am focussing on the interoperability of alls apps built by React, and how the state, some basic behaviors, actions, user interfaces and some experiences can be arranged in order for it to be more modular.<br> <br>While a backend project is usually divided into more than one NPM package, a cross platform app is suggested to be a monorepo.</p><p><em>The closer the code, the faster to write the code;</em> they say, instead of having a git repository for each module which is considered a best practice when thinking in micro-services, it scales better to maintain your frontend code in a single repository.</p><p>To join all dependencies for all platforms within a single React app tends to make things faster in small projects but harder to maintain in big ones.</p><h3>but … IT CAN WORK</h3><p>When looking into the existing boilerplates for react-native-web, all of them are focused on the idea of sharing the <em>package.json</em> for android iOS and web, but mixing web and mobile platform is not good on the long term.<br> <br> I found it is tempting to fall into that idea because of the following:</p><ul><li><em>package.json</em> is easier to maintain</li><li>babel-preset-react-native is recommended by react-native-web and by react-native.</li><li>react-native-web plays well with react-native</li><li>webpack well configured and the RN packager removes unnecessary out of the platform code.</li><li>jest can run in either platforms</li><li>you will have a monolithic bundle one way or another</li></ul><p>The bad parts of not splitting the platform when it comes to the degree of modularity, the scalability and the maintainability of each platform:</p><ul><li>your code is not portable</li><li>you might want a version of a given shared dependency in the web another one in the mobile</li><li>jest and flow can run in either platform but not in all ones</li><li>your favorite editor is not aware of the platform.</li></ul><h3>The platform should be a plugin</h3><p>In an ideal world, the platform should be plugged into the code, not the code plugged into the platform.<br><br>From that statement some questions may arise such as of how should I orchestrate my app if I want it to run it in expo, a new version of react-native on iOS and on an stable one in Android?<br> <br>Or what if I want to have an stable version of any given package like maps, in production environment, and an alpha version of the same package using expo?<br> <br>Or what if I want to evaluate the performance when running it using <em>haul</em> vs using the <em>metro bundler</em>?</p><p><em>As of today</em> when we talk about platform we mean ios, android, windows and web, but sketch, VR and videogames can be thought as a platform as well as in the future it could be the Web GL or an autonomous car.</p><h3>Lerna to the rescue</h3><p>Having a web-mobile project in a lerna-style monorepo could be a great choice when you aim to share JS logic in your app.</p><p>In addition to improving it architecturally, allow semantic releases, and symlinking your components, your app will scale much better on the long term.</p><p>For doing that you should have a module per platform, and consume shared modules using <em>native</em> <em>iOS</em> <em>android</em> and <em>web</em> file extensions as needed.</p><p>You can have peerDependencies on those ones so that each platform can define their specific version, but that should be handled carefully to avoid incompatibilities.</p><p>… and your code without being 100% platform agnostic, will be a step further from being platform specific.</p><h3>react-native-web-workspace</h3><p><a href="https://github.com/agrcrobles/react-native-web-workspace">agrcrobles/react-native-web-workspace</a></p><p>I created this minimum boilerplate that has configured a react-native app packaged with <strong><em>haul</em></strong> sharing somes libraries with the web environment using <strong><em>react-native-web</em></strong><em> </em>to have it as a usefull working example.</p><h3><strong>create-react-workspace</strong></h3><p><a href="https://github.com/ericvicenti/create-react-workspace">ericvicenti/create-react-workspace</a></p><p>This great new project aims to solve out by the <em>cli</em> the way the code is shared between React web apps, React Native apps, and standalone libraries.<br>It’s in alpha stage but it looks promising on the long term.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c6aa6aed818" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hello-js/a-cross-platform-app-with-react-in-a-monorepo-9c6aa6aed818">A cross platform app with React in a monorepo</a> was originally published in <a href="https://medium.com/hello-js">hello JS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>