<?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 Fredrik Seidl on Medium]]></title>
        <description><![CDATA[Stories by Fredrik Seidl on Medium]]></description>
        <link>https://medium.com/@fseidl?source=rss-33f0f7f46ece------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4JK7BYY8cHBe4qn2NqX_IA@2x.jpeg</url>
            <title>Stories by Fredrik Seidl on Medium</title>
            <link>https://medium.com/@fseidl?source=rss-33f0f7f46ece------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:56:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fseidl/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 18 has landed]]></title>
            <link>https://medium.com/upsales-engineering/react-18-has-landed-b7c14ad2ca00?source=rss-33f0f7f46ece------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7c14ad2ca00</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Fredrik Seidl]]></dc:creator>
            <pubDate>Tue, 03 May 2022 15:03:34 GMT</pubDate>
            <atom:updated>2022-05-05T09:07:51.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QAhkF1n92DeGEF53IAvulQ.jpeg" /></figure><p>It’s been a long wait without any updates to the largest front-end library React. In October 2020 the previous major release came out and now we’ve been given the latest and greatest React v18. This article will cover some of the news and how to move to the latest version.</p><h3>News</h3><h4>Better performance</h4><p>React has always been snappy to use. However with React 18 we get even better performance due to automatic batching of renders. Previously React was able to batch multiple state changes into one render from React events, such as the onClick when the user clicked a button.</p><p>In React 18 this will be improved and work even from other places such as timers, promises and native events. This will reduce the number of unnecessary renders and let the CPU do more important things.</p><p>Another performance improvement is the introduction of concurrent features such as startTransition which allows you to tell React that an update is not urgent. By putting things within the callback of startTransition you’re basically telling React to put off rendering of the changes that happen inside of the callback so they happen whenever it has time.</p><pre>import { startTransition } from &#39;react&#39;;</pre><pre>// Urgent: Show what was typed<br>setInputValue(input);// Mark any state updates inside as transitions</pre><pre>startTransition(() =&gt; {<br>  // Transition: Show the results<br>  setSearchQuery(input);<br>});</pre><p>Transitions are expected to be implemented by libraries within time</p><h3>Suspense</h3><p>Suspense has been a part of React since React 16 however still in an experimental fashion. In React 18 it’s being marked as <strong>stable</strong> which is great. The most common use-case is still to use it for code splitting like this</p><pre>import React, { lazy } from &#39;react&#39;;<br>const LazyComponent = lazy(() =&gt; import(&#39;./LazyComponent&#39;));</pre><pre>export default function App() {<br>    return (<br>        &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>            &lt;LazyComponent /&gt;<br>        &lt;/Suspense&gt;<br>    )<br>}</pre><p>But the expectation is that libraries will play a big part in making this big. The plan is that in the future use Suspense for fetching data, loading images, importing more code etc.</p><p>Suspense also gets support for server side rendering which will play a large part in the future of React.</p><h3>New hooks</h3><p>Hooks are here to stay, the React team are introducing several new hooks for us to use out of the box, here are the two that we’re most excited for.</p><p>useId which generates a unique ID. Do not use this in iterators as a key though, there the recommendation is to generate a key from the data in the list</p><p>useTransition returns the startTransition function for you to use for less important state changes</p><p>Read more about the hooks <a href="https://reactjs.org/docs/hooks-reference.html#usetransition">here</a></p><h3>How to move to React 18</h3><p>As always before updating, make sure that your application is free from warnings in the console. The React team are great at providing deprecations to ensure that you can upgrade to the coming version easily.</p><p>React 18 comes with a new root API that you need to use in order to get the new concurrent features.</p><p>Instead of using ReactDOM.render to mount the root component you should switch to ReactDOM.createRoot which accepts the container. After you’ve created the root you can then call the render function on it to render your application.</p><p>If you at some point in the lifecycle of your application want to unmount your application you call the unmount function of the root. Instead of using ReactDOM.unmountComponentAtNode which was the previous way of doing so.</p><p>If you are using Sever side rendering you need to switch from renderToString and renderToNodeStream and instead use renderToPipeableStream or renderToStaticNodeStream</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7c14ad2ca00" width="1" height="1" alt=""><hr><p><a href="https://medium.com/upsales-engineering/react-18-has-landed-b7c14ad2ca00">React 18 has landed</a> was originally published in <a href="https://medium.com/upsales-engineering">Upsales Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fetch-API finally in NodeJS]]></title>
            <link>https://medium.com/upsales-engineering/fetch-api-finally-in-nodejs-ec3000ae8e39?source=rss-33f0f7f46ece------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec3000ae8e39</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[fetch-api]]></category>
            <dc:creator><![CDATA[Fredrik Seidl]]></dc:creator>
            <pubDate>Thu, 17 Mar 2022 08:47:14 GMT</pubDate>
            <atom:updated>2022-03-17T08:47:14.335Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xw2bNJNjX_vDwpfc2WdIA.jpeg" /></figure><p>When building software you will most likely come across a situation where you need to communicate with an external API of some sort. When it comes to Javascript the original way of doing so is by using an API called XMLHttpRequest which despite its name can be used to send and retrieve other datatypes than XML. When it comes to NodeJS we’ve been provided with a similar framework http to handle HTTP requests natively.</p><p>XMLHttpRequest and http are however quite low-level frameworks and are built around events. Making them a bit clunky to use in todays code, where asynchronous code is more commonly handled using callbacks, promises or async/await. Therefore the open-source community have built a lot of different libraries to make it easier for developers to make HTTP requests. An early library for this was jQuery with their ajax module. Other libraries include axios and request who also provide a better interface for developers to use.</p><p>Since 2015 the Fetch API has been available for use in most major internet browsers, providing a much simpler API for developers to use when making HTTP requests. Fetch is Promise based, making it perfect to use in todays code, it has been focused to handle the more common cases needed today. Such as parsing responses as JSON, caching and streaming responses.</p><p>However this API has not been available in NodeJS where we’ve been forced to stick with third party libraries. Meaning that if you want to work full-stack with NodeJS on the backend then you either have to include one of those libraries for your frontend, or remember different ways of making HTTP requests for your frontend and backend. The rise of node-fetch which mimics the fetch API for Node shows how much developers want to work with this API across the stack.</p><p>Which makes us happy to see that since NodeJS 17.5 we will have the fetch API available to use in our backend code as well without any extra dependencies. It’s still experimental and to enable it you need to start node with a flag --experimental-fetch but we encourage you to turn it on and try it out. The new implementation is based on Undici which provides <a href="https://undici.nodejs.org/#/?id=benchmarks">significant improvements in latency and throughput</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec3000ae8e39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/upsales-engineering/fetch-api-finally-in-nodejs-ec3000ae8e39">Fetch-API finally in NodeJS</a> was originally published in <a href="https://medium.com/upsales-engineering">Upsales Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Where to begin testing with years worth of code?]]></title>
            <link>https://medium.com/upsales-engineering/where-to-begin-testing-with-years-worth-of-code-710ce2ab9936?source=rss-33f0f7f46ece------2</link>
            <guid isPermaLink="false">https://medium.com/p/710ce2ab9936</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Fredrik Seidl]]></dc:creator>
            <pubDate>Mon, 27 Apr 2020 11:45:33 GMT</pubDate>
            <atom:updated>2020-04-27T11:45:33.173Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iqxx3u7xOM9tlSA2TXPQPQ.jpeg" /></figure><p>When I started working at Upsales a few years back I can really remember the sudden weird feeling amongst everyone in the office one day — everyone was on edge and the door to the product development team was shut. I soon found out that there had been a deploy last evening and people worked late and arrived early to make sure customers could use the system the morning after.</p><p>This was, unfortunately, the reality that the company was facing several times a year. People didn’t know if a deploy would take 10 minutes or 2 hours. Even though there were both pre-staging and staging environments before moving code to production things decided to break at last second. Why? I want to say that a huge part of it was the lack of automated testing.</p><p>At the time there were some test suites available, but they were too flaky so they didn’t run in any environments and had quickly become obsolete. When I joined the product development team I too had to experience these chaotic deployments more than once.</p><h4>First attempt</h4><p>There have since been a few attempts to get started with testing. The first time I was involved we wrote tests that read our data models and made fake function calls accordingly. This gave us a large test suite with little code but few of them were failing since they could always provide correct data. And the times they did fail it was mostly just to re-run the suite and it passed.</p><p><em>Lesson learned: tests that read the code will rarely fail as they do exactly what the code expects</em></p><h4>Second attempt</h4><p>A few months passed, the test suites that read the code was in place — it ran at each build and failed sometimes (rarely for the right reason though). We still had deploys where stuff broke and no-one knew why.</p><p>Next attempt — enter E2E tests that opens a browser and clicks on buttons as an end-user would. We took a few weeks — built the infrastructure needed and wrote heaps of tests. Great job — now let&#39;s go back to writing new features again. However, this suite was way to slow to run locally and only ran nightly against our pre-staging and staging environments where all new code was. Slowly one by one the tests started failing, no one suspected that they were the one to break them so no one took care of it. To run the entire suite on their local environments before merging to pre-staging would cause the developer to not be able to work for hours. These tests were also really timing dependent, if something took longer than usual to load the entire suite failed. We also had no way to measure code coverage across our services.</p><p><em>Lesson learned: E2E tests are not the primary test form, they are too slow, hard to debug if they failed and provide no way of knowing your code coverage.</em></p><h4>Third times a charm</h4><p>When the third time to take care of the testing problem came around we had also changed how our development workflow was. Which I also believe is a huge reason why it’s working for us. When a developer is done working on their bug/feature they could with the click of a button start-up a pre-staging environment of their branch only. So instead of one pre-staging in total, we had one per feature. (<em>Read more about our pre-staging environments </em><a href="https://medium.com/upsales-engineering/the-alpha-is-down-again-63ec4ccd81be"><em>here</em></a><em>)</em></p><p>This gave us the possibility to also run the entire test suite in isolation on every branch without stopping the developer from working on their next task. If the tests fail the developer is notified and we can for sure know which branch it is that made the tests break before having to debug it in production. We implemented tools to measure coverage on our tests. By doing so we could see the coverage on the entire project, and also the coverage on the diff of the branch.</p><p>We decided to enforce at least 90% diff coverage on ALL pull requests. That way all new code is tested and all old code gets better coverage every time a developer has to touch it. The ability to view coverage on the diff made all the difference for us as we could not enforce 90% coverage in an entire project with lots of existing code.</p><p><em>Lesson learned: have the infrastructure to run all tests on all branches, set a threshold for what the coverage should be and enforce it.</em></p><p>We are still evolving and learning every day. But we don’t have to work late evenings and early mornings to clean up messes after deploys anymore and the rest of the company don’t feel on edge every time deploy-days come around which is a huge step forward.</p><p>Got any testing tips and tricks? I would love to discuss this with you in the comment section. Liked this article? Give it some claps 👏👏👏</p><p><em>Psst — Want to work with the best in class product with great colleagues? Check out our job pages </em><a href="https://www.upsales.com/en/about-upsales/careers/?utm_source=medium"><em>here</em></a><em>. Not looking for a job but a world-class CRM and Marketing platform? Sign up for a trial of Upsales </em><a href="https://www.upsales.com/en/free-trial/?utm_source=medium"><em>here</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=710ce2ab9936" width="1" height="1" alt=""><hr><p><a href="https://medium.com/upsales-engineering/where-to-begin-testing-with-years-worth-of-code-710ce2ab9936">Where to begin testing with years worth of code?</a> was originally published in <a href="https://medium.com/upsales-engineering">Upsales Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>