<?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 Raul Sposito on Medium]]></title>
        <description><![CDATA[Stories by Raul Sposito on Medium]]></description>
        <link>https://medium.com/@raulsposito?source=rss-ab59e5bbe6c7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AZiM9XfjLvXQvYNcaPc8Rg.jpeg</url>
            <title>Stories by Raul Sposito on Medium</title>
            <link>https://medium.com/@raulsposito?source=rss-ab59e5bbe6c7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:28:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raulsposito/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[Having fun with useScroll in VueJS]]></title>
            <link>https://medium.com/arionkoder-engineering/having-fun-with-usescroll-in-vuejs-3ac552949b82?source=rss-ab59e5bbe6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ac552949b82</guid>
            <category><![CDATA[vueuse]]></category>
            <category><![CDATA[vuejs-2]]></category>
            <category><![CDATA[vue]]></category>
            <dc:creator><![CDATA[Raul Sposito]]></dc:creator>
            <pubDate>Fri, 28 Oct 2022 14:11:25 GMT</pubDate>
            <atom:updated>2022-11-14T18:55:34.606Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*vFRMjFrWrWu8ppL7JhMdJw.png" /><figcaption>Vite + VueUse</figcaption></figure><p>There’s an amazing collection of composition utilities called <a href="https://vueuse.org/">VueUse</a> and if you don’t know about it make sure to check it out because there’s a ton of cool stuff there that will make your everyday development a lot simpler.</p><p>We will cover a few fun use cases for the <a href="https://vueuse.org/core/useScroll/">useScroll</a> utility and how that can, with very few lines of code, achieve some cool reactive effects in our layouts.</p><p>To get started, just run npm i @vueuse/core on the terminal and make sure you import import { useScroll } from &#39;@vueuse/core&#39; into the component you&#39;re going to be listening for scroll events.</p><p>In this example, I’m also using ‘ref’ so you would need to import import { ref } from &#39;vue&#39;; as well as instantiate an element in the script with that &#39;ref&#39;. Looking like this:</p><pre>&lt;script setup&gt;<br>import { ref } from &#39;vue&#39;;<br>import { useScroll } from &#39;@vueuse/core&#39;;<br><br>const el = ref(null);<br>const scroll = useScroll(el);<br>&lt;/script&gt;</pre><p>Cool! We have assigned a ref to an element and we will be listening for all the scrolls on it. Now we need to reference that in the template so our users can actually scroll over it.</p><pre>&lt;template&gt;<br>  &lt;div class=&quot;scroll-box&quot; ref=&quot;el&quot;&gt;<br>    “It is a period of civil war. Rebel spaceships, striking from a hidden base,<br>    have won their first victory against the evil Galactic Empire. During the<br>    battle, Rebel spies managed to steal secret plans to the Empire’s ultimate<br>    weapon, the DEATH STAR, and space station with enough power to destroy an<br>    entire planet. Pursued by the Empire’s sinister agents, Princess Leia races<br>    home aboard her starship, custodian of the stolen plans that can save her<br>    people and restore freedom to the galaxy….”<br>  &lt;/div&gt;<br>  &lt;div&gt;{{ scroll }}&lt;/div&gt;<br>&lt;/template&gt;</pre><p>As you can see, we are using that same ref to link it together and inside that element, we have placed a long text (Star Wars opening Crawl) that will overflow the container and enable its ability to be scrollable. For this, we will also need to use CSS to set a max height, or height to that container and to also enable for overflow: scroll;. It will look like the following:</p><pre>&lt;style scoped&gt;<br>.scroll-box {<br>  color: white;<br>  background-color: black;<br>  height: 150px;<br>  width: 100%;<br>  overflow: scroll;<br>  position: relative;<br>}<br>&lt;/style&gt;</pre><p>With that, we have enough to get started on the magic!</p><p>Here’s the fun part, useScroll returns us an object that we can play with and do all our creativity allows us to. The object will look like the following:</p><pre>{ &quot;x&quot;: 0, &quot;y&quot;: 0, &quot;isScrolling&quot;: false, &quot;arrivedState&quot;: { &quot;left&quot;: true, &quot;right&quot;: true, &quot;top&quot;: true, &quot;bottom&quot;: false }, &quot;directions&quot;: { &quot;left&quot;: false, &quot;right&quot;: false, &quot;top&quot;: false, &quot;bottom&quot;: false } }</pre><p>And you can actually go ahead and print it on the screen, to see what I’m talking about.</p><pre>&lt;div&gt;{{ scroll }}&lt;/div&gt;</pre><p>So now you get the idea of where this is going.</p><p>Let’s say we want to perform a certain action whenever our user has reached the end of the scroll, something like showing or hiding something. We can use the “arrivedState” property of our use scroll and listen for it when it reaches “bottom” (when bottom = true).</p><p>So we can add conditional render to the element we want to add and link that to our useScroll object, as follows:</p><pre>&lt;p v-show=&quot;scroll.arrivedState.bottom&quot;&gt;you have reached the bottom!&lt;/p&gt;</pre><p>I also added a simple button to be able to click on it and reset the whole flow without having to reload the page. It’s not the fanciest but it does the job for this example.</p><p>Feel free to check out the whole code example on <a href="https://stackblitz.com/edit/vitejs-vite-xkr9a8">Stackblitz</a>!</p><p>Imagine also that you would like to add some animation or display something while the user is performing the scroll, to give it some sense of dynamism. You can also listen for the “isScrolling” attribute of the useScroll object and link that to trigger the animation! Or you can listen for a given point in the “y” axis and fire events or display different content based on it.</p><p>The possibilities are only limited by what we can imagine :) since the technical part is now super simple!</p><p>Hope you enjoyed this since it’s the first of a series regarding this wonderful VueUse library.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ac552949b82" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arionkoder-engineering/having-fun-with-usescroll-in-vuejs-3ac552949b82">Having fun with useScroll in VueJS</a> was originally published in <a href="https://medium.com/arionkoder-engineering">Arionkoder Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native for Web Apps]]></title>
            <link>https://medium.com/arionkoder-engineering/react-native-for-web-apps-20c20d0ed15e?source=rss-ab59e5bbe6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/20c20d0ed15e</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-native-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Raul Sposito]]></dc:creator>
            <pubDate>Wed, 26 Oct 2022 15:04:21 GMT</pubDate>
            <atom:updated>2022-11-14T18:55:25.100Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*UI4B_tKfeRUpvEvaWpGxhA.gif" /><figcaption>Write once run anywhere!</figcaption></figure><p>Wouldn’t it be cool if we could just write an app once? Instead of having to create a native version for mobile and then develop a whole new codebase for a Web App? Wouldn’t it be much more time/cost-effective?</p><p>React Native is a full JavaScript framework and one of the cool things it does is that it translates the React Native tags into Native tags, to Kotlin/Java in the case of Android and to Swift/ObjC in the case of IOS.</p><p>So in the case of adding a View tag, it would translate to ViewGroup in Kotlin or UIView in the case of Swift. And we don’t have to worry about all that, RN just does it for us.</p><p>So following this logic, we should just have a package that translates the native modules into HTML elements compiled on the browser, and that way we can just create the build for the web, using the same code we use to deploy the Native version for Google Play or App Store.</p><p>That package is <a href="https://www.npmjs.com/package/react-native-web">react-native-web</a></p><p>And you can also learn a lot more about it <a href="https://necolas.github.io/react-native-web/">here</a>.</p><p>If you’re thinking this is crazy or kind of a long shot, let me tell you several names in the industry (big names) use this same package to build their web apps from their actual React Native codebase.</p><p>With this package we can create a new build for the web that we can deploy to AWS amplify or Firebase hosting or whatever host you like. It would be a full web build you can deploy. :)</p><p>So we’re covered! We have IOS, Android, and Desktop and we only had to code it once.</p><p>Unless you’re making something super intricate or specific in your app, this should cover most simple projects or MVPs.</p><p>Let’s take a look in more detail at how all this is done, step by step:</p><p>You will first need several dependencies to run the React Native CLI. (Node, watchman, cocoa pods, react-native)<br>And also x-code which is super heavy and takes a bit to download from <a href="https://developer.apple.com/xcode/">the official apple link</a>.</p><p>Make sure the Node version is 14 or above.</p><p>You can get more details on alternative setups <a href="https://reactnative.dev/docs/environment-setup">here</a>.</p><p>Then, you can choose to start the project with just React Native or we can use Expo which would simplify the build process for us whenever we are exporting for the web.</p><p><strong>As with any react project</strong>, node package execute:</p><p>`<strong>npx react-native init my-awesome-project</strong>`</p><p><strong>As Expo project</strong>:</p><p><strong>`npm install — global expo-cli &amp;&amp; npx create-expo-app my-awesome-project`</strong></p><p>As you would expect this will create the basic template and folder structure for you to start working on your project.</p><p>Then to start the project `<strong>npx react-native start`</strong> or `<strong>npx expo start`</strong></p><p>This will start the metro bundler and pull up our project on the emulator.</p><p>Ok, now let’s make it web!</p><p>We need to add the dependencies `<strong>npm install react-dom react-native-web`</strong></p><p>Cool, so after the installation we can pull up the project and we should see it in both mobile and web versions if we decide to go to the browser and type the localhost port, we should see the web version of our app.</p><p>In that web version, you might want to go ahead and inspect the page just to find out that it’s no longer React Native elements, they’re actually <em>html</em> in the browser now. The <em>views</em> got compiled into <em>html</em>.</p><p>Alright, how do we extract all this into a build so we can host it on our server?</p><p>The easiest way I know would be <strong>with Expo</strong>:</p><p><strong>`expo build:web`</strong></p><p>This will generate the new build in a root-level folder and that content we can host wherever we like on the web!</p><p>For the <strong>traditional version</strong> we should follow the docs advice and install a few plugins for optimization first:</p><p><strong>`npm install — save-dev babel-plugin-react-native-web`</strong></p><p>This Babel plugin is recommended for the build.</p><p>Next, we would need to alias our <strong>react-native</strong> into <strong>react-native-web</strong> so babel-plugin-module-resolver is required.</p><p><strong>`npm install — save-dev babel-plugin-module-resolver`</strong></p><p>This will all be configured from our webpack config file, so go ahead and add the following to your <strong>babel.config.js</strong> file:</p><p><strong>`npm install — save-dev babel-plugin-module-resolver`</strong></p><p>All good so far, now for our web version we will need to create two entry files living at root path. <strong>index.html</strong> and <strong>index.web.js</strong>.</p><p>/index.html</p><pre>html<br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=”en”&gt;<br> &lt;head&gt;<br> &lt;meta charset=”utf-8&quot; /&gt;<br> &lt;title&gt;React Native on the Web!&lt;/title&gt;<br> &lt;meta content=”initial-scale=1,width=device-width” name=”viewport” /&gt;<br> &lt;meta httpEquiv=”X-UA-Compatible” content=”IE=edge” /&gt;<br> &lt;style&gt;<br> /* These styles make the body full-height */<br> html,<br> body,<br> #root {<br> height: 100%;<br> }<br> /* These styles disable body scrolling if you are using &lt;ScrollView&gt; */<br> body {<br> overflow: hidden;<br> }<br> /* These styles make the root element flex and column wise filling */<br> #root {<br> display: flex;<br> flex-direction: column;<br> }<br> &lt;/style&gt;<br> &lt;/head&gt;<br> &lt;body&gt;<br> &lt;div id=”react-native-web-app”&gt;&lt;/div&gt;<br> &lt;script type=”text/javascript” src=”/bundle.web.js”&gt;&lt;/script&gt;<br> &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Notice the script name src=”/bundle.web.js”, We’ll be using this file name while configuring webpack.</p><pre>/index.web.js<br>import React from &#39;react&#39;;<br>import {AppRegistry} from &#39;react-native&#39;;<br>import App from &#39;./src/components/App&#39;;<br>import {name as appName} from &#39;./app.json&#39;;<br><br>AppRegistry.registerComponent(appName, () =&gt; App);<br><br>AppRegistry.runApplication(appName, {<br>  rootTag: document.getElementById(&#39;react-native-web-app&#39;),<br>});</pre><p>If you look at the file above, you might notice that on the third line `import App from ‘./src/components/App’;` I’m importing an App component, which is different from our standard output for our React Native App. This is because, we will need a differential output for this build to happen, otherwise we would get an error because of the imports we are using that are not part of the RN public API.</p><p>For example:</p><pre>javascript<br>import {<br> Colors,<br> Header,<br> ReloadInstructions,<br>} from ‘react-native/Libraries/NewAppScreen’;</pre><p>As stated by Nicolas Gallagher in <a href="https://github.com/necolas/react-native-web/discussions/2052">this discussion</a>.</p><p><em>&gt; “First, we should not be loading any of the RN package on web, especially not parts that aren’t part of the public API . Second, as mentioned in the inline comments of the config web/webpack.config.js, we need to explicitly list everything in node_modules that needs compiling.”</em></p><p>So this is basically why we create a different file, to reference as output. And that file would not have the imports or would not be referencing any of the library components we used for our Mobile version. This will have to be resolved in a ‘web’ way for this one.</p><p>Great! We got ahead of that issue and are back on track for our export.</p><p>Next, we’ll need to dive into Compiling and Bundling using Webpack for bundling and Babel for transpiling along with babel-loader.</p><p><strong>`npm install — save-dev babel-loader url-loader webpack webpack-cli webpack-dev-server`</strong></p><p><strong>`npm install — save-dev babel-plugin-react-native-web`</strong></p><p>Cool, now let’s create a `/web/webpack.config.js` file and start configuring webpack using the <a href="https://necolas.github.io/react-native-web/docs/multi-platform/">official docs</a> with a small twist to add jsx support ;).</p><p>`webpack.config.js`:</p><pre>const path = require(&#39;path&#39;);<br>const webpack = require(&#39;webpack&#39;);<br><br>const appDirectory = path.resolve(__dirname, &#39;../&#39;);<br><br>const babelLoaderConfiguration = {<br>  test: /\.(js)|(jsx)$/,<br>  // Add every directory that needs to be compiled by Babel during the build.<br>  include: [<br>    path.resolve(appDirectory, &#39;index.web.js&#39;),<br>    path.resolve(appDirectory, &#39;src&#39;),<br>    path.resolve(appDirectory, &#39;node_modules/react-native-uncompiled&#39;),<br>  ],<br>  use: {<br>    loader: &#39;babel-loader&#39;,<br>    options: {<br>      cacheDirectory: true,<br>      // The &#39;metro-react-native-babel-preset&#39; preset is recommended to match React Native&#39;s packager<br>      presets: [&#39;module:metro-react-native-babel-preset&#39;],<br>      // Re-write paths to import only the modules needed by the app<br>      plugins: [<br>        &#39;react-native-web&#39;,<br>        [<br>          &#39;module-resolver&#39;,<br>          {<br>            alias: {<br>              &#39;^react-native$&#39;: &#39;react-native-web&#39;,<br>            },<br>          },<br>        ],<br>      ],<br>    },<br>  },<br>};<br><br>// This is needed for webpack to import static images in JavaScript files.<br>const imageLoaderConfiguration = {<br>  test: /\.(gif|jpe?g|png|svg)$/,<br>  use: {<br>    loader: &#39;url-loader&#39;,<br>    options: {<br>      name: &#39;[name].[ext]&#39;,<br>      esModule: false,<br>    },<br>  },<br>};<br><br>module.exports = {<br>  entry: [<br>    // load any web API polyfills<br>    // path.resolve(appDirectory, &#39;polyfills-web.js&#39;),<br>    // your web-specific entry file<br>    path.resolve(appDirectory, &#39;index.web.js&#39;),<br>  ],<br><br>  // configures where the build ends up<br>  output: {<br>    filename: &#39;bundle.web.js&#39;,<br>    path: path.resolve(appDirectory, &#39;dist&#39;),<br>  },<br><br>  // ...the rest of your config<br><br>  module: {<br>    rules: [babelLoaderConfiguration, imageLoaderConfiguration],<br>  },<br><br>  resolve: {<br>    // This will only alias the exact import &quot;react-native&quot;<br>    alias: {<br>      &#39;react-native$&#39;: &#39;react-native-web&#39;,<br>    },<br>    // If you&#39;re working on a multi-platform React Native app, web-specific<br>    // module implementations should be written in files using the extension<br>    // `.web.js`.<br>    extensions: [&#39;.web.js&#39;, &#39;.js&#39;, &#39;.jsx&#39;],<br>  },<br>};</pre><p>We are ALMOST there!</p><p>Just need to set up which scripts we’ll be using to actually run this on the web. So let’s take a look at `/package.json`:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;web&quot;: &quot;webpack serve -d source-map --mode development --config \&quot;./web/webpack.config.js\&quot; --inline --color --hot&quot;,<br>    &quot;build:web&quot;: &quot;webpack --mode production --config \&quot;./web/webpack.config.js\&quot; --hot&quot;<br>  }<br>}</pre><p>After adding the correct scripts we should be able to run <strong>npm run web</strong> on the command line and get our app to run!</p><p>You might want to navigate to port <a href="http://localhost:8080/">http://localhost:8080</a> to see your webapp running.</p><p>**Conclusion:**<br>As you might have noticed, the Expo path is waaaay simpler and gets a lot done for you. If you want to dive into the regular RN way, I really hope this guide serves a purpose for that matter.</p><p>I would recommend using the tools available to make it simple, as stated on the official docs:</p><p>&gt; “If you are interested in making a multi-platform app it is strongly recommended that you use Expo (or learn from the source code for the Web integration). Expo includes web support and takes care of all the configuration work required.”</p><p>Feel free to build for ANY platform!</p><p>Hope you enjoyed the extensive article :)</p><p><a href="https://necolas.github.io/react-native-web">react-native-web docs</a><br><a href="https://necolas.github.io/react-native-web/docs/multi-platform/">Multi-Platform-React-Native</a><br><a href="https://necolas.github.io/react-native-web/docs/setup/">Setup — react-native-web</a><br><a href="https://dev.to/shivams136/create-react-native-app-for-android-ios-and-web-without-expo-48lc">React Native for Web without Expo — by shivams136</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20c20d0ed15e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arionkoder-engineering/react-native-for-web-apps-20c20d0ed15e">React Native for Web Apps</a> was originally published in <a href="https://medium.com/arionkoder-engineering">Arionkoder Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>