In How to write a React Component in TypeScript, I typed an example React component. Here’s where we left off: const operations = { '+': (left: number, right: number): number => left + right, '-': (left: number, right: number): number ...
Here’s our component without types: const operations = { '+': (left, right) => left + right, '-': (left, right) => left - right, '*': (left, right) => left * right, '/': (left, right) => left / right, } function Calculator({left, ...
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 showed some examples and I want to call out a ...
For over half of 2021, I worked on a complete rewrite of kentcdodds.com. You’re reading this on the rewrite of this site! Are you using dark mode or light mode? Have you signed in and selected your team yet? Have ...
Alrighty, let’s talk about this: const reportError = ({message}) => { // send the error to our logging service... } try { throw new Error('Oh no!') } catch (error) { // we'll proceed, but let's report it reportError({message: error.message}) } ...