10 Ways to Speed Up React Development
Tags: javascript, react, webdev, productivity
Published: 2020-11-16 17:37:12

As much as I love writing React applications, I'd prefer not to. I'd rather have finished hours ago so I can spend time either on a beach outside my computer or in a videogame within it. In the spirit of laziness, here are ten ways to accelerate your React development.

## 1. Use a Framework

Frameworks remove degrees of freedom from the developer. You have fewer decisions because thousands of brilliant open-source developers have made them for you. At least nine times out of ten their decisions are better than yours would have been, unless you're Dan Abramov (if you are Dan Abramov, notice me, senpai). Follow the roadmap the framework sets forth to save time and write more consistent and robust code.

My favorite React framework is [Next.js](https://github.com/vercel/next.js). You get SSR, built-in routing, automatic codesplitting, CSS-in-JS support, and more. You can even write lambdas that share business logic (such as types and validation) with your client-side code. If you host a Next.js app on [Vercel](https://vercel.com), you can deploy a free, infinitely scalable application just by pushing to GitHub.

Other great frameworks include [Gatsby.js](https://github.com/gatsbyjs/gatsby) and [Remix](https://remix.run/).

Even if you decide not to use a framework, you should at least use a boilerplate generator such as [create-react-app](https://github.com/facebook/create-react-app).

## 2. Use ESLint

I hope you're already using [ESLint](https://www.github.com/eslint/eslint). There's no excuse to not use extremely configurable code that alerts you when you make mistakes. Two ESLint plugins are particularly helpful (and I'd argue essential) for React:

- [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react)
- [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)

## 3. Use Prettier

Similarly to ESLint, you should use [Prettier](https://prettier.io/), an opinionated code formatter. Prettier integrates with most editors to automatically format your code on save, ensuring a consistent style. I'm all for our robot overlords taking away our freedom to get creative about trivialities.

## 4. Use AI-Driven Autocomplete

I hope that the first three suggestions were unsurprising. Using a framework, ESLint, and Prettier are par for the course if you're a JavaScript developer in 2020. This next suggestion is still a bit under the radar. It's my favorite developer tool to spring on friends to show I can still consort with JS hipsters.

Fully give in to the aforementioned robot overlords and use AI-driven autocomplete. My favorite so far is [TabNine](https://www.tabnine.com). You're probably rolling your eyes at the tech buzzwords, but try it and get back to me. You'll be impressed.

## 5. Superpower your CLI

Go a step beyond only empowering your JavaScript and plunge into the wonderful world of CLI tools. I recommend a few in particular:

- [Oh My Zsh](https://ohmyz.sh/): augment your Zsh configuration with thousands of helpful functions, helpers, plugins, themes, etc.
- [Scaffolder](https://github.com/galElmalah/scaffolder): painlessly generate boilerplate code.
- [ZSH-z](https://github.com/agkozak/zsh-z): quickly jump to directories you've recently visited.

## 6. Use a React Component Library

Unless you work for a giant company that already has an internal component library, you'll almost certainly want to use one that's pre-built. I can no longer bear the thought of writing tomes of `div`s and `p`s instead of endlessly configurable `Box`s and `Text`s. Admire the intuitive elegance of Chakra UI (taken from their website):

```javascript
import * as React from "react";
import { Box, Image, Flex, Badge, Text } from "@chakra-ui/core";
import { MdStar } from "react-icons/md";

export default function Example() {
  return (
    <Box p="5" maxW="320px" borderWidth="1px">
      <Image borderRadius="md" src="https://bit.ly/2k1H1t6" />
      <Flex align="baseline" mt={2}>
        <Badge colorScheme="pink">Plus</Badge>
        <Text
          ml={2}
          textTransform="uppercase"
          fontSize="sm"
          fontWeight="bold"
          color="pink.800"
        >
          Verified &bull; Cape Town
        </Text>
      </Flex>
      <Text mt={2} fontSize="xl" fontWeight="semibold" lineHeight="short">
        Modern, Chic Penthouse with Mountain, City & Sea Views
      </Text>
      <Text mt={2}>$119/night</Text>
      <Flex mt={2} align="center">
        <Box as={MdStar} color="orange.400" />
        <Text ml={1} fontSize="sm">
          <b>4.84</b> (190)
        </Text>
      </Flex>
    </Box>
  );
}
```

Chakra UI is my favorite component library and is accelerating in popularity. Others include [Rebass](https://github.com/rebassjs/rebass) and [Base Web](https://github.com/uber/baseweb).

## 7. Use a CSS-in-JS library

Even when using a component library, you might need to write CSS. It's like JavaScript's mostly inescapable stepsibling. Your best option is to write CSS in JavaScript, which allows for tighter scoping of styles to components, explicit dependencies, less cascading, and other benefits. A lot of the cool kids have started to use [Linaria](https://github.com/callstack/linaria). Linaria doesn't carry the performance costs of other CSS-in-JS libraries because it extracts CSS files during buildtime, resulting in zero runtime.

Other devs enjoy [Emotion](https://github.com/emotion-js/emotion), [Styled Components](https://github.com/callstack/linaria), and [JSS](https://github.com/cssinjs/jss).

## 8. Use Storybook

[Storybook](https://storybook.js.org/) allows you to quickly prototype React components in isolation from the app's business logic. You can mock different configurations of props to determine how your component will render. An underappreciated benefit of Storybook is that it enforces a clearly delineated architecture. I typically build as much of my application as possible within storybook, mocking increasingly complex components and even pages. By the time I start on the business logic, a wrapper component will be responsible only for providing props to my presentational ones. My smart components are completely separate from my dumb ones. If you haven't yet, read this classic [article](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0) on smart versus dumb components.

## 9. Don't Write Your Own Forms

Learning to write forms in vanilla React is important. It forces the developer to recognize the difference between controlled and uncontrolled components, master state management, etc. When writing production code, however, you'll almost certainly want to use a library. A good form library will not only save you time, but it will also be less prone to bugs.

You may be thinking, "Aha, but I want to asynchronously validate user input," or, "What if one input depends on another?" No, there's a form library for these and 99% of all other use cases. I recommend [Formik](https://formik.org/), but [React Final Form](https://github.com/final-form/react-final-form) and [React Hook Form](https://github.com/react-hook-form/react-hook-form) are other favorites.

## 10. Don't Reinvent the Wheel

React is a godsend to lazy programmers. All of the most complicated generalizable components are already written! If you find yourself writing a table, or an autocomplete component, or animation utilities, or if you're importing SVGs for icons, stop writing `const Table =` and search for a library. These are some of my favorites:

- [Framer Motion](https://www.framer.com/motion/): for animations;
- [React Table](https://github.com/tannerlinsley/react-table): for tables;
- [React Icons](https://react-icons.github.io/react-icons/): for icons;
- [React Draggable](https://github.com/STRML/react-draggable): for making elements draggable;
- [React Autosuggest](https://github.com/moroshko/react-autosuggest): for autocomplete;
- [React Datepicker](https://github.com/Hacker0x01/react-datepicker/): for datepicking.

### About Us

At [Carrots](https://thecarrots.io) we're building a hiring platform specifically for software engineers. You can connect your GitHub, Stack Overflow, and more to go beyond your resume. Our algorithm shows where you rank among world-class talent and surfaces your profile to top companies. Check out our [Telegram channel](https://t.me/softwaredevjobs) for a live feed of developer jobs.