<?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 Maurice Wallbott on Medium]]></title>
        <description><![CDATA[Stories by Maurice Wallbott on Medium]]></description>
        <link>https://medium.com/@maurice.wallbott?source=rss-ee5fa775e868------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eKvHBFON0UdGmVeQ9ZfEcw.jpeg</url>
            <title>Stories by Maurice Wallbott on Medium</title>
            <link>https://medium.com/@maurice.wallbott?source=rss-ee5fa775e868------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:14:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maurice.wallbott/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[React hook – incremental release with feature flags]]></title>
            <link>https://medium.com/@maurice.wallbott/why-and-how-feature-toggles-with-react-hooks-2b0f0d5d49ab?source=rss-ee5fa775e868------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b0f0d5d49ab</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[releases]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[feature-toggles]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Maurice Wallbott]]></dc:creator>
            <pubDate>Sat, 16 Oct 2021 11:10:02 GMT</pubDate>
            <atom:updated>2021-11-06T08:18:07.873Z</atom:updated>
            <content:encoded><![CDATA[<h4>Implementation of a react hook for feature flags/toggles.</h4><blockquote>Feature Toggle, aka Feature Flags (FT), is an implementation detail to disable or enable a feature on the fly without changing or deploying new code. For example, this technique can allow red/green deployments or a/b testing.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*pSv8v86d4cxI4EFE4HzD9w.png" /></figure><p>Hey 👋 are you just looking for a working solution?<br>Check out my CodeSandbox: <a href="https://codesandbox.io/s/react-hook-featurtoggles-ktbw0">https://codesandbox.io/s/react-hook-featurtoggles-ktbw0</a></p><h3>Why Feature Toggles?</h3><p>We use Feature Toggles to decouple our feature releases from deployments. This allows us to push changes already to live without showing it to our users and avoid dealing with long-living and big feature branches. Furthermore, Feature Toggles let us release a feature to a smaller group first, without directly scaring all users with potential problems with the new feature (Canary Release). In addition, we were now able to implement two different ideas of a new feature and present both solutions, one group at a time. Here, we could test which solution ultimately led to a higher conversion rate and was more understandable or appealing to our users.</p><p>Technically, it’s just an if-else statement that we can control for this user from the outside.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/49de840a2cbb2eb23ee21c797f453c3b/href">https://medium.com/media/49de840a2cbb2eb23ee21c797f453c3b/href</a></iframe><p>It is super simple but powerful.</p><h3>How can I implement it with a custom React hook?</h3><p>We will build a custom react hook in the coming examples and extend it by updating the toggle over query parameter and persist the value in a browser cookie.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e726168cfba0baa99180e4e8e38cabb/href">https://medium.com/media/9e726168cfba0baa99180e4e8e38cabb/href</a></iframe><p>Let’s use our simple hook and render the “<em>newLoginPage”</em> based on our Feature Toggle.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25bb918ade5edc39e71169982a0dd0cb/href">https://medium.com/media/25bb918ade5edc39e71169982a0dd0cb/href</a></iframe><p>To change the value of the toggle, we read the new value from the URL query parameter and change the state accordingly.</p><p>The value of a query parameter is always a string. Therefore, to parse the value correctly, we can create a helper function that converts the value to a boolean accordingly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e0e5b522024a4649b2329542ef08095/href">https://medium.com/media/1e0e5b522024a4649b2329542ef08095/href</a></iframe><p>Now we can use this function and read our feature toggles with the correct value from the query parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04c894ffc625595198d855ed2a106bbb/href">https://medium.com/media/04c894ffc625595198d855ed2a106bbb/href</a></iframe><p>From now on we can control our “<em>newLoginPage”</em> toggle via a query parameter. For example, we can display the new page with these parameters:<br>“<em>?newLoginPage=true” </em>or<em> “?newLoginPage=1” </em>or<em> “?newLoginPage=yes”</em></p><p>To keep the status of the toggle up to date, even if the user reloads the page, we can add it to the Browser Cookies, SessionStorge or similar.</p><p>In this example, I have chosen a cookie that is updated when the query parameter is changed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4dc329e8d4d24d504f66ae5580bbafa/href">https://medium.com/media/c4dc329e8d4d24d504f66ae5580bbafa/href</a></iframe><p>Furthermore, we could prefix our Feature Toggles and add a filter for our query parameters to get only valid query toggles.</p><p>But this should be it for now from the implementation. If you have any other ideas or questions, feel free to leave a comment.</p><h3>How can I control the toggles from outside?</h3><p>Since we can now configure the toggles per user session, we need some sort of remote control and management of the toggles.</p><p>We decided on a SaaS solution to configure the toggles more easily from the outside (<a href="https://launchdarkly.com/">https://launchdarkly.com/</a>). But there are also a bunch of free tools available.</p><p>First, we load the remote configuration from the server with the first user request and add it to the FeatureToggleProvider as our initial state. We request the toggles after our user request since we want to perform possible A/B tests for specific user properties. (Logged in or not, user group, etc.) Nevertheless, overriding the toggle via the query parameter or cookie makes testing different configurations per session possible.</p><h3>What problems may arise?</h3><p>I’m sure you’ve wondered what problems Feature Toggles can cause and how we deal with them, so here we go.</p><p>One of the problems we identified is stale/old feature toggles and code. We wanted to solve this problem with a process. So, whenever we implement a feature toggle, a ticket is directly created to remove the toggle in a future sprint (after a defined period). That has worked quite well so far. Nevertheless, it happens from time to time that we move these tickets further. Because the tests are running longer or there is no decision yet.</p><p>Another problem is some flakiness with our end-to-end tests and integration tests with other teams. Since we run some of our features via an A/B test, we need to support at least two different tests. These tests must have at any time the correct feature toggles. Here, we use the cookie option to set a toggle accordingly before we start the test. Because other teams also provide some functions on our site, they also need to restructure their tests to work as they should. Most of the time to change the test is not a big deal. But to be honest, good communication with all dependent teams before turning on a feature or running an A/B test is now a must to avoid frustration with beloved colleagues.</p><p>Another challenge, which I would like to mention only briefly, is tracking. Since we base our analysis and findings on tracking, we must be careful when implementing feature toggles to implement our tracking correctly and not mess up existing data.</p><p>This was my second blog post, which turned out to be longer than planned. 😇I hope you liked it.</p><p>Thanks for reading, and have fun implementing your feature toggles. 🏅</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b0f0d5d49ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic react rerendering optimizations.]]></title>
            <link>https://medium.com/@maurice.wallbott/basic-react-rerendering-optimizations-f41f564cb27?source=rss-ee5fa775e868------2</link>
            <guid isPermaLink="false">https://medium.com/p/f41f564cb27</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Maurice Wallbott]]></dc:creator>
            <pubDate>Wed, 08 Sep 2021 19:29:10 GMT</pubDate>
            <atom:updated>2021-09-08T19:29:10.136Z</atom:updated>
            <content:encoded><![CDATA[<p>We all come at some point to think about React Component optimizations. Most of the time, we want to reduce unnecessary re-renders. In my first blog post, I want to show you some basic things we can do before using the big hammer like React.memo().</p><h4><strong><em>TL;DR:</em></strong></h4><blockquote>We can often make a re-render faster by restructuring our code and moving the state change from the existing component to a separate one. Bring the state as close as possible to the component and follow the single responsibility principle.</blockquote><blockquote>It’s simple: If you give React the same element as the previous render, it will not re-render this component.</blockquote><h3>Let’s check a Small React Shop-Example:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*d4jrGXvAAWI_wYsRT3D40g.png" /><figcaption>React component with rerendering issue</figcaption></figure><p><a href="https://codesandbox.io/s/react-rendering-slow-5i85t?file=/src/App.js">https://codesandbox.io/s/react-rendering-slow-5i85t?file=/src/App.js</a></p><p>This example demonstrates our small e-commerce webshop with a search bar and an artificial super slow homepage component. The search value will change whenever the user types, and unfortunately, the slow homepage component re-renders.</p><p>Technically, for every input change, we will trigger a state change. The state change causes a re-render of &lt;SlowHomepage/&gt; which blocks the rendering of the whole App Component.</p><p>We could wrap React.memo() around our SlowHomepage Component to fix the issue. However, we can also do a different thing and stick to simple React basics.</p><h3><strong>Solution: Extract state change as a separate component</strong></h3><p>If the structure of our component allows us to do so, we can move the state. In our case, we can migrate the search to a new component. This way, the state change no longer affects the rendering of the slow component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*XdMdbeMXlClr3bGuPOvapQ.png" /><figcaption>Optimization by extracting the components</figcaption></figure><p><a href="https://codesandbox.io/s/react-rendering-optimized-1-b6t5q">https://codesandbox.io/s/react-rendering-optimized-1-b6t5q</a></p><p>If our structure is slightly different and we need the search result above the SlowHomepage Component, we need to do something else. <em>(</em><a href="https://reactjs.org/docs/lifting-state-up.html"><em>https://reactjs.org/docs/lifting-state-up.html</em></a><em>)</em> Since a component only re-renders when the state or props change, which also applies to children, we can take advantage of this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*d2XxyhorI1RWcOYYZ0ZsPQ.png" /><figcaption>Optimization by restructuring the code</figcaption></figure><p><a href="https://codesandbox.io/s/react-rendering-optimized-2-4v1es?file=/src/App.js">https://codesandbox.io/s/react-rendering-optimized-2-4v1es?file=/src/App.js</a></p><p>Now we render the SlowHomepage Component in the parent and pass it as children. If the wrapper re-renders and the children are the same as the previous ones, React will not re-render the SlowHomepage Component.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f41f564cb27" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>