This site runs best with JavaScript enabled.
Looking for something specific? Search for a blogpost here.

How to implement useState with useReducer

Here's the TL;DR: Wanna dive in? Let's go. But Kent... Why? For fun 🤓 Also I think that re-implementing things is a great way to learn how they work. State management in React React hooks expose two mechanisms for state management: useState and useReducer . Interestingly enough, React actually…

Read →

Write fewer, longer tests

Imagine we have this UI that renders a loading spinner until some data is loaded: Here's what that would render (I added a "Re-mount" button so you can try making it re-load. I also made it fail 50% of the time): Let's talk about testing this component. I'm going to mock out the api.getCourseInfo…

Read →

JavaScript to Know for React

Current Available Translations: Türkçe One of the things I love most about React compared to other frameworks that I've used is how exposed you are to JavaScript when you're using it. There's no template DSL (JSX compiles to sensible JavaScript), the component API has only gotten simpler with the…

Read →

How to get experience as a software engineer

Current Available Translations: Türkçe Here's the secret: More Problems, More Experience Here's one thing that I've observed in my time as a career software engineer: There's no shortcut to experience. You have to put in the time. That said, there are things that you can do to ensure that your…

Read →

5 Tips to Help You Avoid React Hooks Pitfalls

The React Hooks feature was proposed in October 2018 and released ~4 months later in February 2019. Since then, people have been rapidly learning and adopting hooks in their production codebases because hooks drastically simplify the management of state and side effects in applications. It…

Read →

Avoid Nesting when you're Testing

I want to show you something. What I'm going to show is a general testing principle, applied to a React component test. So even though the example is a React one, hopefully it helps communicate the concept properly. Note: my point isn't that nesting is bad by itself, but rather that it naturally…

Read →

When to break up a component into multiple components

Current Available Translations: Korean Did you know that you could write any React Application as a single React Component? There's absolutely nothing technically stopping React from putting your entire application into one giant component. Your function would be HUGE. There'd be a TON of hooks for…

Read →