Best of Kent C. Dodds2021

  1. 1
    Article
    Avatar of kentcdoddsKent C. Dodds·4y

    Why I Love Remix

    Remix enables me to build amazing user experiences and still be happy with the code I had to write to get there. kentcdodds.com is completely custom built by me using Remix. After writing tens of thousands of lines of code using this framework, I have developed a great appreciation for what this framework can do for me.

  2. 2
    Article
    Avatar of kentcdoddsKent C. Dodds·5y

    JavaScript Pass By Value Function Parameters

    In JavaScript, when you call a function with arguments, the arguments you're passing are passed by value, not by reference. When a new function is created, it looks around for all the variables it has access to and "closes over" them to form a "closure" This means that so long as this logger function exists, it will have access to the variables in its parent's function.

  3. 3
    Article
    Avatar of kentcdoddsKent C. Dodds·5y

    How to use React Context effectively

    In Application State Management with React, I talk about how using a mix of local state and React Context can help you manage state well in any React application. I want to show you how you can create React context consumers effectively so you avoid some problems and improve the developer experience and maintainability.

  4. 4
    Article
    Avatar of kentcdoddsKent C. Dodds·5y

    How to write a React Component in TypeScript

    A common method to typing a React component is to use one of the generics that are built-into @types/react (I mean, it's built-in right? So what could go wrong?). Interestingly, you cannot type a function declaration this way, so we'll have to use a function expression. For functions, you need to consider the types coming in and the types going out.

  5. 5
    Article
    Avatar of kentcdoddsKent C. Dodds·5y

    Listify a JavaScript Array

    Intl.List Format is a way to display a list of items to a user. Because it's coming from the Intl standard, a TON of locales are supported, so you can get internationalization for "free" There's also a lesser-known localeMatcher option which can be configured to either 'lookup' or 'best fit'

  6. 6
    Article
    Avatar of kentcdoddsKent C. Dodds·5y

    Wrapping React.useState with TypeScript

    I made a useDarkMode hook that looks like this. It powers the "dark mode" support for all the Epic React workshop apps (for example React Fundamentals) I want to call out a few things about the hook itself that made things work well from a TypeScript perspective. Let's clear out all the extra stuff and just look at the important bits.