<?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 Rob Burgess on Medium]]></title>
        <description><![CDATA[Stories by Rob Burgess on Medium]]></description>
        <link>https://medium.com/@rcbdev?source=rss-2899e3263efe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*p9XzsfRrBmxZXaCDyK8E7Q.jpeg</url>
            <title>Stories by Rob Burgess on Medium</title>
            <link>https://medium.com/@rcbdev?source=rss-2899e3263efe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:41:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rcbdev/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[I’m Hooked]]></title>
            <link>https://medium.com/waterstons-development/im-hooked-7b09a36edac0?source=rss-2899e3263efe------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b09a36edac0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Rob Burgess]]></dc:creator>
            <pubDate>Fri, 05 Apr 2019 13:12:39 GMT</pubDate>
            <atom:updated>2019-04-05T13:12:39.684Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OwHtndgwCFCOCic9" /><figcaption>Photo by <a href="https://unsplash.com/@teracomp?utm_source=medium&amp;utm_medium=referral">Dave Phillips</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You’ve probably read a lot about React Hooks already. People telling you they’re revolutionary and you should rewrite all your code now. Others saying how terrible Hooks are and how their alternative is a lot better. Tutorials showing Hooks improving code in scenario X. This article will be a little different.</p><p>When I first saw React Hooks announce by Dan Abramov I was a little sceptical. How is this better than my higher order components or render props? I can’t use these in conditionals? They require a consistent call order to work?!?! These sound like a nightmare! But I was also highly sceptical when I first saw React. You put HTML in my JavaScript? Sacré bleu, layout and code should be kept separate! But then I gave it a go and it was great. Maybe the React team know better than me and these Hook things are alright. So I gave them a go too…</p><p>Initially it was a little challenging unlearning the old class based ways of thinking. Your state isn’t a single object holding all data for a component anymore. You can actually have multiple state objects within the same component, with each storing data related to a specific concern. This doesn’t seem so bad!</p><p>Now that my state’s broken up into different concerns, perhaps I can separate things even more. I’ve got code for listening to the window resize and storing the current width/height. Could that be a custom hook? Yes, my component now just says const windowSize = useWindowSize(); (<a href="https://gist.github.com/rcbdev/1b96a6c9ddcf11c0e45980732b02fbf4">source</a>). Much better. I no longer have event subscriptions cluttering up my code. I can also use that same hook elsewhere and not have to manage subscriptions in each component’s mount/unmount. This just keeps getting better.</p><p>What else can Hooks clean up for me? Fetching data for a component when it mounts can end up being a bit of a repetitive coding task. How can Hooks improve that? A simple custom hook lets me remove the scattered boilerplate code normally required from this sort of task and have a nice one line solution in the component. Before I was handling both componentDidMount and componentDidUpdate , storing a loading indicator and data in state, and implementing a function for handling the fetch. Now I simply have const [data, loading] = useData(`https://myurl.com/data?param=${prop}`); (<a href="https://gist.github.com/rcbdev/64993c9129bf93b8b833cdc3afeddc1a">source</a>). This is night and day for the component’s readability. No more logic dispersed across a component, and I instantly see the intent of the code.</p><p>I’m now hooked 😉. Rewriting a relatively complex screen with Hooks as resulted in a much cleaner and more maintainable set of code. Some of the problems Hooks solve <em>could</em> be solved with other methods such as higher order components or render props, but those come with their own challenges. Increased nesting, harder to read code, and hidden intents.</p><p>Yes, Hooks can be seen as “magic” or a “black box”, but so is a lot of React! Do you <strong>actually</strong> know what happens when you call this.setState? How about how context gets shared down a component tree? Unless you’ve worked on the React core, I’m guessing the answer is no. If you’re on the fence about React Hooks, or don’t like them for some reason, please try them out. Pick a part of an application you’ve worked on that was a little challenging and try rewriting it with Hooks. Work through the initial struggle and see how it improves. I was a doubter and now I’m hooked. Sorry I doubted you <a href="https://medium.com/u/a3a8af6addc1">Dan Abramov</a>, Hooks truly are the future!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b09a36edac0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/waterstons-development/im-hooked-7b09a36edac0">I’m Hooked</a> was originally published in <a href="https://medium.com/waterstons-development">Waterstons Development</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why We Use React]]></title>
            <link>https://medium.com/waterstons-development/why-we-use-react-b8ce646087bd?source=rss-2899e3263efe------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8ce646087bd</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Rob Burgess]]></dc:creator>
            <pubDate>Mon, 28 May 2018 17:54:29 GMT</pubDate>
            <atom:updated>2018-05-30T16:15:22.158Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3Yg2pTqUCYmVyTJI." /><figcaption>“Close-up of a laptop screen with lines of code” by <a href="https://unsplash.com/@sapegin?utm_source=medium&amp;utm_medium=referral">Artem Sapegin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>At Waterstons we use React as our front end development library of choice. After having used many different options, from jQuery assisted DOM manipulation to full front end frameworks like knockout, we realised we needed to decide upon a standard platform to build our websites on. We reviewed all the modern (and not so modern) options available and settled on React. This is why.</p><h4>What We Need</h4><p>Different companies need different things in a front end framework or library. For us, we need something that works across the wide range of projects we deliver. This meant it has to be applicable to both brand new greenfield solutions, as well as enhancing existing applications. We need to be able to develop both single page applications (SPAs) and multi-page applications (MPAs). We also want flexibility in our solutions, allowing us to use the right tool for a given problem.</p><h4>The Competitors</h4><p>You likely already know the big players out there in the front end development space. React, Angular, and Vue.js. There are others out there that we looked into (e.g. Aurelia), but these are by far and away the biggest three. Each has their own unique positives and benefits, and just because React is right for us doesn’t mean it’s right for you.</p><h4>React</h4><p>Let’s start with React. React was created by Facebook in order to power their website, and was first released back in 2013. It’s gained huge traction over the past few years and is now the library of choice for many large websites. Facebook, BBC, Uber, Netflix to name a few. React has quickly become the biggest front end library, leaving other trailing. So what is React?</p><ul><li><strong>A view engine:</strong> React is not a front end framework. There is no built in routing. No HTTP library. No state management library. This can be a blessing or a curse. If you want to just run one npm install and have everything you need, React probably isn’t for you. If you want the freedom to use the libraries you want, React will fit you perfectly.</li><li><strong>JSX:</strong> React and JSX go hand in hand. Nobody uses React without JSX (although technically it’s possible to do so). But, JSX can be divisive. “You’re putting HTML in JavaScript?!?!” This was my reaction initially. As an outsider, it can look weird. It might even seem completely wrong. Give it a go though, and you’ll fall in love. Why learn a whole new language just to do a repeating section in your template, when you can just use .map() ?</li></ul><h4><strong>Angular</strong></h4><p>Angular is almost the polar opposite of React. Created by Google, and going through a major transition phase in 2016, Angular is a full front end development framework. Google use Angular on some of their sites, but not on their biggest platforms (search &amp; YouTube). It’s also used by some big companies, for example NFL Game Pass, but not nearly as many as React. Angular’s main defining points are:</p><ul><li><strong>A full framework:</strong> If you want to just install your npm package and go, Angular may be for you. It includes everything you need to develop a modern website. View engine, HTTP library, client side routing, dependency inject. If you want to replace any of these with your library of choice, you may have difficulties.</li><li><strong>TypeScript:</strong> Angular and TypeScript are best friends. Starting with the big 2.0 rewrite, Angular has pushed forwards with TypeScript and made it the language of choice. This means you get build time type checking and automated documentation in your IDE. I won’t go in to all the benefits of TypeScript as there’s plenty of articles on that. TypeScript is not unique to Angular, and can be used with other libraries/frameworks too.</li><li><strong>Templates:</strong> Unlike React, Angular uses templates for layouts. This separates your TypeScript from you layouts, but means you need to learn the Angular specific syntax for binding, loops, conditional renders, etc.</li></ul><h4>Vue.js</h4><p>Vue.js is like React and Angular had a child. It takes concepts from React, and concepts from Angular, resulting in a framework that has developed a healthy following. It’s not backed by a large company, but it is used by some big players. GitLab, Nintendo, and Sainsbury’s all use Vue.js. Vue.js differentiates itself by being:</p><ul><li><strong>A library or a framework:</strong> If you just want to use the core Vue.js view library, you can. If you want to bring along all the goodies, that’s OK. Vue.js gives you the option.</li><li><strong>Fast</strong>: This is one of the key points that got people interested in Vue.js. It’s fast at rendering, and also quick to pick up and work with. Other libraries are now up and matching it for performance, but Vue.js still pushes the boundaries on performance.</li><li><strong>Templates:</strong> Like Angular, Vue.js prefers templates. This means learning the Vue.js template language, which can be a blocker to getting started.</li></ul><h4>So Why React?</h4><p>After all this, why did we go for React?</p><ol><li><strong>Stable, with good future.</strong> React is backed, and used, by Facebook. They are heavily invested in it and have no plans to retire it any time soon. New versions are treated with care, and migration paths are important. This is a big factor for us as we write systems that will likely still be in use and supported in ten years time.</li><li><strong>Can be added progressively.</strong> We wanted to be able to enhance existing apps easily, and React allows as to do this. It’s not an all or nothing approach, and we can add React to pages (or parts of pages) where needed.</li><li><strong>Familiar.</strong> As React doesn’t use a template language, it does not introduce an extra element to learn. If you are familiar with JavaScript, you can get started with React fairly quickly.</li><li><strong>Flexible.</strong> React works just as well on MPAs as it does on SPAs. You can also choose the best libraries for your project. If you want to use fetch you can. Equally, if you want to use Axios you can. React doesn’t care.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8ce646087bd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/waterstons-development/why-we-use-react-b8ce646087bd">Why We Use React</a> was originally published in <a href="https://medium.com/waterstons-development">Waterstons Development</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prettier - Make Your JavaScript Beautiful]]></title>
            <link>https://medium.com/waterstons-development/prettier-make-your-javascript-beautiful-8dc301eaa664?source=rss-2899e3263efe------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dc301eaa664</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[formatting-code]]></category>
            <category><![CDATA[prettier]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Rob Burgess]]></dc:creator>
            <pubDate>Wed, 23 May 2018 09:03:19 GMT</pubDate>
            <atom:updated>2018-05-23T09:03:19.712Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-_tE3a8qIIiCf-Mn." /><figcaption>Photo by <a href="https://unsplash.com/@mr_vero?utm_source=medium&amp;utm_medium=referral">Irvan Smith</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Prettier — Make Your JavaScript Beautiful</h3><p>Code formatting can be a challenging problem to solve. Everyone knows ideally you should have a standard, but having to manually format your code can be a pain. When do you decide to split code out over multiple lines? Should your brackets be on the same line as the if statement or the line after? Why did someone leave multiple blanks lines in this file? Luckily “Prettier” exists to solve these problems for our front end code.</p><h4><strong>​What is Prettier?</strong></h4><p>​Prettier is a library you can add to your project to automatically apply complex formatting rules to all your JavaScript (and TypeScript) files. It’s an intelligent code formatter that understands your code and applies rules based on what your are doing. It is highly opinionated​, but the defaults are sensible and you dont’ have to configure much. Straight out of the box, it does a very good job of tidying all your JavaScript files.</p><h4><strong>​How to use it​</strong></h4><p>So, how do we use Prettier? At the most basic level, it’s simply a case of running:</p><pre>​​​​yarn add prettier --dev --exact<br>yarn prettier --write “**/*.js”​</pre><p>​​This will install prettier and run it on all “.js” files in the current directory and all subdirectories. It is, however, a manual process we have to run. Like all manual processes, it will soon be forgotten and no longer used. We can automate it though.</p><h4><strong>Git Hooks</strong></h4><p>If we’re using Git for our source control (sorry TFVC), automating Prettier is super simple. Git includes a feature called “Git Hooks”, which allows you to run tasks before and after Git events (e.g. “precommit”). This allows us to run prettier on all our JavaScript files prior to committing to source control. You can continue to code in whatever style you like, but badly formatted code will never hit your source control server.</p><p>To set up Git Hooks with prettier, we need a few npm packages. Husky to easily set up the Git Hooks, lint-staged to process staged files, and of course Prettier itself to format our code. Run the below to install them all</p><pre>​​yard add prettier husky lint-staged --dev</pre><p>​Now that they’re all installed, we need to update our package.json. Husky runs scripts based on the available Git Hooks. The one we want is “precommit”. Update your “scripts” in package.json to have:</p><pre>{<br>  “precommit”: “lint-staged”<br>​}</pre><p>​This simply runs “lint-staged” before committing, so we now need to tell lint-staged what to do. Still in the package.json, add the below at the top level:​</p><pre>{<br>  &quot;lint-staged&quot;: {<br>    &quot;gitDir&quot;: &quot;{path traversal to your git repo, e.g. ../../}&quot;,<br>    &quot;linters&quot;: {<br>      &quot;*.js&quot;: [<br>        &quot;prettier --write&quot;,<br>        &quot;git add&quot;<br>      ]<br>    }<br>  }<br>}</pre><p>This tells lint-staged a few things. First it tells us where our git directory is so it can find the staged files. Secondly, we tell it what to run. This configuration says “for all .js files that are staged, run prettier and then stage the result”. This means every time you commit a JavaScript file, it is automatically formatted by prettier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dc301eaa664" width="1" height="1" alt=""><hr><p><a href="https://medium.com/waterstons-development/prettier-make-your-javascript-beautiful-8dc301eaa664">Prettier - Make Your JavaScript Beautiful</a> was originally published in <a href="https://medium.com/waterstons-development">Waterstons Development</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>