<?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 Daniel Duong on Medium]]></title>
        <description><![CDATA[Stories by Daniel Duong on Medium]]></description>
        <link>https://medium.com/@duongasaur?source=rss-c2f31c0535d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Np3n9GvvW1EijHTP</url>
            <title>Stories by Daniel Duong on Medium</title>
            <link>https://medium.com/@duongasaur?source=rss-c2f31c0535d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:32:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@duongasaur/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[Where hooks fall short]]></title>
            <link>https://duongasaur.medium.com/where-hooks-fall-short-746a64382e36?source=rss-c2f31c0535d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/746a64382e36</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Daniel Duong]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 04:19:39 GMT</pubDate>
            <atom:updated>2021-03-31T04:23:26.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*CHEGm6nQU1XJSImw6DbVZw.jpeg" /></figure><p>We can all agree react hooks are great. Especially for reusability and abstraction of non-display logic.</p><p>However all of the <strong>control</strong> is on the component layer.<br>Which means there is very limited composition, not very functional.<br>Especially when dealing with external dependencies like redux.</p><p>For purpose of demonstration I will be mainly focusing on redux hooks. The same concepts apply to context-provider hooks like react-router hooks.<br>Take this example of an input connected to state and prefixed by currency :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79cb17d4c5a2b560e522bdba68c652ab/href">https://medium.com/media/79cb17d4c5a2b560e522bdba68c652ab/href</a></iframe><p>This is a cut down version of an existing complicated component.</p><p>In order to compose the component and reuse the display you would either need to:<br>A. Dependency inject the onChangeHook and selector<br>B. Add a isCurrencyInput prop along with two if conditions<br>C. Container - View pattern</p><p><strong>Re-presenting….</strong><br>Redux.connect the higher order component</p><p>Higher order components let us invert control of the base component.<br>Allowing us to compose at the file layer. <br>Here I will demonstrate writing a text input that shares all of the display of currency input.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6aae6c63cd039d52a27bdd8851c02224/href">https://medium.com/media/6aae6c63cd039d52a27bdd8851c02224/href</a></iframe><p>Voila! We have now created two components with separation of concerns that share the same JSX and Styles. Not a single line of code repeated.<br>When practicing this composition pattern. It also becomes very clear which state or data is used for display logic versus state that is used for sideEffects like onClick. This separation forces you to put that data into thunks/sagas which means less state inside the component and <strong>less re-renders</strong>.</p><p>🔥Thank you for reading 🔥</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=746a64382e36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Animating unMount in React with CSS3 transitions]]></title>
            <link>https://duongasaur.medium.com/animating-unmount-in-react-with-css3-transitions-15c80fab1aff?source=rss-c2f31c0535d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/15c80fab1aff</guid>
            <category><![CDATA[css3]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[css-transition]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Daniel Duong]]></dc:creator>
            <pubDate>Sun, 24 Nov 2019 04:08:35 GMT</pubDate>
            <atom:updated>2019-11-24T04:08:35.557Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xr9-eW0jaENOm_T9dEIoRQ.png" /></figure><p>The problem with animating react components with css3 transitions is that react with unMount your component before the animation is done.</p><p>Your immediate solution would be some form of setTimeout and state.<br>We all know that would be a code smell in the form of complexity and performance.</p><p>Introducing: The transition end event !!! 😱🤯 🙀<br><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/transitionend_event">https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/transitionend_event</a></p><p>If you don’t already know. You can add eventListeners to elements in React using refs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0420c4ef411295e5bc078213bf932f2a/href">https://medium.com/media/0420c4ef411295e5bc078213bf932f2a/href</a></iframe><p>Now the next step would be to tell your component weather or not the div has finished transitioning. In order to do that we have state in the custom hook.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01ec4d8d03bcdb8107b43931a6241fd4/href">https://medium.com/media/01ec4d8d03bcdb8107b43931a6241fd4/href</a></iframe><p>So now our hook is looking more useful. But we still need some kind of safe boolean for our show/hide state. So let’s pass that value into our hook and the isAnimating flag becomes the safe show/hide that accounts for transition times.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c0d6bed9adf6c179d471e47f707111c/href">https://medium.com/media/5c0d6bed9adf6c179d471e47f707111c/href</a></iframe><p>The useLayoutEffect is there to set safeShowHide to true when the toggle is true. But <strong>only once</strong>. It will also safely change showHide to true. Since useLayoutEffect can be thought of as a synchronous version of useEffect.</p><p>YOU CAN SEE A WORKING EXAMPLE <a href="https://codesandbox.io/s/use-transition-end-42zij">HERE</a>.</p><p>Thanks for reading. 🐨🐨🐨<br>Please checkout my other articles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15c80fab1aff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improve Your API Calls in Redux Saga]]></title>
            <link>https://duongasaur.medium.com/improve-your-api-calls-in-redux-saga-986e510dbb17?source=rss-c2f31c0535d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/986e510dbb17</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux-saga]]></category>
            <dc:creator><![CDATA[Daniel Duong]]></dc:creator>
            <pubDate>Mon, 16 Sep 2019 12:05:29 GMT</pubDate>
            <atom:updated>2019-09-16T12:05:29.620Z</atom:updated>
            <content:encoded><![CDATA[<p>Applying advanced “vanilla” redux patterns to redux-sagas</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*GW5T6QwtSpwm82dk9Qe-Bw.png" /></figure><p>I’m new to redux-saga, but not to redux. At first It felt like sagas were a whole different world. But in reality there are a lot of parallels. Using generators also means you can create data streams and complex transducers.</p><p>Hands up if you fetch your API data in sagas like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e1746a0b2f33c23bfed63deb65bd555/href">https://medium.com/media/7e1746a0b2f33c23bfed63deb65bd555/href</a></iframe><p>Notice that for every additional action. Would be an additional saga and an additional api call with try and catch. Each original action would be discarded. 😭</p><p>Traditionally, this would be abstracted into an apiMiddleware.<br>The first few lines of which generally look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/703389d4e5a3dc21795510b177fe147e/href">https://medium.com/media/703389d4e5a3dc21795510b177fe147e/href</a></iframe><p>So how would we apply a similar pattern to sagas?<br>After a bit of research, it turns out the take functions are quite flexible.</p><p>As a first parameter they can receive either a string array or function .<br>Using that to our advantage we can write something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0ff786256941b84106a2d0003a39ab7/href">https://medium.com/media/e0ff786256941b84106a2d0003a39ab7/href</a></iframe><p>Notice the similarities? apiCalls can now handle the bulk of all our actions. <br>We dispatch an action to fetch data like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b907b6ecac57762575bc486838f542d3/href">https://medium.com/media/b907b6ecac57762575bc486838f542d3/href</a></iframe><p>The only confusing thing here would be the array of types.<br>Which is your loading, success and fail action type strings.<br>That will be dispatched from the apiCalls saga.<br>The rest is pretty much self explanatory.</p><p>That is …. until you run into an error like:<br>Actions may not have an undefined ‘type&#39; property <br>Which just means that an action flowed through to the finalMiddleware and didn’t have a type property. <br>Normally you would skip over calling next in middleware to skip an action.<br>But sagas can only ever fork actions, passing the original to the next middleware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*9_jZWeRbwVR-yuEa1n6w0g.jpeg" /></figure><p>There are two ways you can solve this.<br>1. You could add an empty string as the type for the action<br>2. Using this to your advantage. You can use the loading type.<br>Option two means that your types array only holds the success and failure types. Also means that your apiCalls saga does less work.</p><p>For a working code example. See my <a href="https://codesandbox.io/s/marvel-app-saga-ik77i">sandbox</a>.</p><p>🎉THANKS FOR READING 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=986e510dbb17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding new functionality? Here’s 5 Techniques for Managing Dependencies in React]]></title>
            <link>https://duongasaur.medium.com/adding-new-functionality-heres-5-techniques-for-managing-dependencies-in-react-91ae2495be4c?source=rss-c2f31c0535d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/91ae2495be4c</guid>
            <category><![CDATA[webworker]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[inversion-of-control]]></category>
            <dc:creator><![CDATA[Daniel Duong]]></dc:creator>
            <pubDate>Wed, 10 Jul 2019 03:41:39 GMT</pubDate>
            <atom:updated>2019-07-10T03:41:39.068Z</atom:updated>
            <content:encoded><![CDATA[<p>In every company I’ve worked for. The same question has repeatedly come up. We need X functionality, how should we include it?</p><p>Before I dive in to the different tools and patterns. Let’s just use Redux as the dependency in all our examples, since it’s the most common.</p><h3>1️⃣ Hoisting</h3><p>You may be thinking.. What does hoisting have to do with dependencies?</p><blockquote><em>Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.</em></blockquote><p>The hackiest way to provide scope of your service would be attaching it to the global object. Depending on your scenario, this could be useful.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8f94ea77cfd6f251f413723d3e9ca76/href">https://medium.com/media/b8f94ea77cfd6f251f413723d3e9ca76/href</a></iframe><p><strong>The proper way to hoist would be to contain the service in it’s own file.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51efcc3178991b3b136d838dadc42ce5/href">https://medium.com/media/51efcc3178991b3b136d838dadc42ce5/href</a></iframe><p>Then no matter how many times you:<br><em>import store from ‘./store’;</em> <br>It will only ever be initialised once. The drawback of this method is that store is initialised immediately.</p><h3>2️⃣ Context Providers</h3><p>This is a very common pattern so I won’t go into too much detail.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b47a820e6c8260f6a314d75b7d20a854/href">https://medium.com/media/b47a820e6c8260f6a314d75b7d20a854/href</a></iframe><p>Providers wrap the main content of your app. Then to consume, you can either use a HigherOrderComponent like connect() or react’s new useContext hook. This means any of your components can have context of the store.</p><h3>3️⃣ Event Bus</h3><p>Now this example will be a bit funny since Redux is used as an Event Bus in it’s own sense. So let us use the browser history as the dependency.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3be80e2ea74319549cb12dfb92b781f/href">https://medium.com/media/e3be80e2ea74319549cb12dfb92b781f/href</a></iframe><p>Now when you dispatch a function, you’ll receive history as the third arg.<br>Realistically you would want to initialise the dependency in a custom middleware. Where you can handle a multitude of scenarios.<br><strong>But you don’t need Redux if all you’re after is an event bus!!!<br></strong>There are much better event bus libraries you could use.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/024ba8fd66b3aec15c57fcf250bc7084/href">https://medium.com/media/024ba8fd66b3aec15c57fcf250bc7084/href</a></iframe><p>So now you can have certain parts of your code emit events. If anything should happen within your dependency, it will.</p><h3>4️⃣ Web Workers</h3><blockquote>Web Workers are a simple means for web content to run scripts in background threads.</blockquote><p>A web worker may be what you need if your service is performance intensive.<br>Or the dependency is quite large in file size and you don’t want it in your bundle. <strong>It also works across multiple tabs!!!</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41504b6b5932885268802f0a52862021/href">https://medium.com/media/41504b6b5932885268802f0a52862021/href</a></iframe><p>This is an simple example on how to subscribe a webworker using comlink.<br>Comlink has the power to proxy functions and send it to your worker.<br>You can read a better explanation <a href="https://davidea.st/articles/comlink-simple-web-worker">here</a>, disclaimer: some of the function names have been renamed/deprecated since that article.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac5abc10aa645c469b85f32520b74999/href">https://medium.com/media/ac5abc10aa645c469b85f32520b74999/href</a></iframe><p>When you spin up the worker. It has no scope of your app. You can only speak to it through a proxy. That means you will have to load your dependency via a package distribution CDN. This can be problematic since the CDN could be down. Which can be solved with a private CDN.</p><h3>5️⃣ IoC Containers</h3><p>So I have saved the best for last. Inversion of control is a popular pattern in other frameworks and languages. It allows you to define service containers that only initialise when you call them. <strong>Best of all, you can compose them!</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2431599376f9ff1a75a4b03e811dba34/href">https://medium.com/media/2431599376f9ff1a75a4b03e811dba34/href</a></iframe><p>In this example we use bottlejs for the dependency injection.<br>Then a hook to access the different services in the container. The service does not initialise until it is called. So in your component you can:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25cddefea8299492e3288c301a0def81/href">https://medium.com/media/25cddefea8299492e3288c301a0def81/href</a></iframe><p>Thanks for reading! 🎉</p><p>Please take a look at my other articles:</p><p><a href="https://medium.com/@duongasaur/redux-strategy-for-experts-b8de0bfc2c20">https://medium.com/@duongasaur/redux-strategy-for-experts-b8de0bfc2c20</a><br><a href="https://medium.com/@duongasaur/a-lightweight-firebase-redux-integration-e7fbc25c764b">https://medium.com/@duongasaur/a-lightweight-firebase-redux-integration-e7fbc25c764b</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91ae2495be4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Redux Strategy for Experts!!!]]></title>
            <link>https://duongasaur.medium.com/redux-strategy-for-experts-b8de0bfc2c20?source=rss-c2f31c0535d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8de0bfc2c20</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[redux-zero]]></category>
            <category><![CDATA[immutability]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[immer]]></category>
            <dc:creator><![CDATA[Daniel Duong]]></dc:creator>
            <pubDate>Mon, 24 Jun 2019 04:28:47 GMT</pubDate>
            <atom:updated>2019-06-24T04:28:47.820Z</atom:updated>
            <content:encoded><![CDATA[<p>Redux Strategy for Experts!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M52pIW1grzNms9SG5DmPcg.jpeg" /></figure><p>Being proficient in react and redux. Chances are, you could probably wire up redux from memory. But the amount of boilerplate code required just to get started can be annoying. <strong>The worst being reducers.</strong></p><p>Redux has one solution for reducing boilerplate. That is their createAction and createReducer utils from <a href="https://redux-starter-kit.js.org/">redux-starter-kit</a>. It lets you create a simple action and reference it in an object inside createReducer.<br>Best of all, the state is immutable thanks to <a href="https://github.com/immerjs/immer">immer</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*u5w3VfoWX4_Byh3oXhk_QA.jpeg" /></figure><p>But let’s take it one step further and eliminate reducers. You don’t need them!<br>Well that’s what <a href="https://github.com/redux-zero/redux-zero">redux-zero</a> is. It’s a <em>zero</em> <em>reducers</em> implementation of redux. Relax, it still has middleware. You can read more on how &amp; why redux-zero <a href="https://medium.com/@matheusml/introducing-redux-zero-bea42214c7ee">here</a>.</p><p>I’m going to show you how to compose it with immer. Because we still want to maintain immutability just like redux-starter-kit.</p><p>This is the standard redux-zero action:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a331fdcda1ab92f3da8a2353a5ec6c45/href">https://medium.com/media/a331fdcda1ab92f3da8a2353a5ec6c45/href</a></iframe><p>This is the standard state update from immer:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b23b68daa9cadc26c62d7cf2fb920f6/href">https://medium.com/media/4b23b68daa9cadc26c62d7cf2fb920f6/href</a></iframe><p>So composing the two, we get:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0e359bb35339d46cef8827abcf9bf6b/href">https://medium.com/media/b0e359bb35339d46cef8827abcf9bf6b/href</a></iframe><p>What’s happening here ?<br>Well in zeroImmer, zeroAction is our regular redux-zero action that can take extra params after state.</p><p>Instead of passing <strong>state</strong> to our zeroAction we wrap it in createNextState where it receives <strong>draft</strong> instead. Along with any arguments it was supposed to have. There you have it.</p><p>How you connect actions in react is slightly different for redux-zero;</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1dd4bc3d19001f885664705a6faa9412/href">https://medium.com/media/1dd4bc3d19001f885664705a6faa9412/href</a></iframe><p>Notice how you don’t need an extra library for the connect, as would be the case in react-redux. Actions don’t need to be bound to dispatch.</p><p>Implementation for a REST API driven app is slightly different.<br>Check out this sandbox, or continue reading:</p><p><a href="https://codesandbox.io/s/redux-zero-immer-5v5f4">Redux Zero Immer - CodeSandbox</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5781e24e17aae9b47fe60c97c151f5d3/href">https://medium.com/media/5781e24e17aae9b47fe60c97c151f5d3/href</a></iframe><p>So what’s the difference ??? For the zeroImmerApi we hoist the response in a thunk. So that at the time it is called in the apiMiddleware we can pass that in before it moves on to the <a href="https://github.com/redux-zero/redux-zero/blob/master/src/middleware/applyMiddleware.ts">final middleware</a>. Where redux-zero will only pass in state to our action that is already composed with immer.</p><p>You can checkout the code for the apiMiddleware in the sandbox link above.<br><strong>PLEASE ASK QUESTIONS.</strong></p><p>Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8de0bfc2c20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Lightweight Firebase + Redux Integration]]></title>
            <link>https://duongasaur.medium.com/a-lightweight-firebase-redux-integration-e7fbc25c764b?source=rss-c2f31c0535d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7fbc25c764b</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[firebaseauthentication]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Daniel Duong]]></dc:creator>
            <pubDate>Fri, 14 Jun 2019 00:23:04 GMT</pubDate>
            <atom:updated>2019-06-14T00:23:04.108Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*ptwftFCHSLrSGyeREWTYGg.png" /></figure><p>If you are wanting to use firebase in your react app. You might have already heard of react-redux-firebase which has ton of documentation in addition to some copy paste startup usage. But at the cost of bundle size and complexity.</p><p>If you are are after something simple, lightweight and want to be selective about what you store in redux. I’m here to rescue you.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cb8446208c9cf28fe5eeabf2ebf66e7/href">https://medium.com/media/2cb8446208c9cf28fe5eeabf2ebf66e7/href</a></iframe><p>This is the basic setup for a firebase app … 5 lines. You may want to import your config through an env file.</p><p>Next we create a custom middleware. It helps if you have done this before.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a7647a403e6a13e82d705c2b23fe01e/href">https://medium.com/media/9a7647a403e6a13e82d705c2b23fe01e/href</a></iframe><p>So this can look quite complicated. Not to mention it is slightly deviated from the version I use. ( I use my own version of createAction from redux-starter-kit ). Basically you send a withFirebase function along with your FIREBASE action and the middlware calls it with firebase as the first param, the auth providers as the second param. It expects a promise as the result of the function.</p><p><strong>The handle function is a pattern I took from this </strong><a href="https://www.freecodecamp.org/news/my-favourite-line-of-code-53627668aab4/"><strong>article</strong></a><strong>.</strong></p><p>If you don’t already know how to apply middelware:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d95dca50e7b65ca7f028cc424769b208/href">https://medium.com/media/d95dca50e7b65ca7f028cc424769b208/href</a></iframe><p>Next this is how you would utilise the middleware with an action:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a150f39ba04ed1047e819f80b4499574/href">https://medium.com/media/a150f39ba04ed1047e819f80b4499574/href</a></iframe><p>Enjoy.<br>If you have any questions or feedback. Please comment below.<br>If this article has helped you, also let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7fbc25c764b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>