Tag: typescript

TypeScript Tuples

TypeScript offers a plethora of types for developers to leverage, but some of the types may be ones that you’re unfamiliar with. Take the tuple, for example. JavaScript doesn’t have a concept of tuples, so figuring out how and when to use one might feel tricky. Thankfully, Tuples are pretty simple and are used by… Read more »

Managing Authentication with React’s useContext Hook

Contexts are a commonly used tool when building React libraries, but are often overlooked when building an application in React. I don’t believe that should be the case, as useContext can provide you a powerful alternative (but lightweight) alternative to tools like Redux when managed carefully. The classic example of using a context is to… Read more »

How do I use TypeScript with React?

React is allowing developers to iterate faster and build safer, more reliable frontend applications than we were building many years ago. TypeScript, a relatively new addition to the “JavaScript Alternatives” scene, also aims to add a new level of safety in the form of type safety. Naturally, it makes sense for us to want to… Read more »

Typescript – What is a Partial?

A common theme in TypeScript is to define an interface for a data structure. Additionally, it’s fairly common to post data structures to an HTTP endpoint to create resources. You may even find yourself posting another structure with some of the same properties to update that data structure. Instead of creating another interface for the… Read more »

Fetching Data with React Hooks

React hooks have changed the way that I (and arguably the React Community) prefer to build components. I’ve been working on a GraphQL project for a while, and when we migrated to functional components and hooks, I was able to use Apollo’s hooks for my data fetching needs. However, I find myself now working on… Read more »

Auth Guarding React Router Routes

A common theme in web applications is to serve specific content to authenticated users while serving other content to everyone else. I’ve heard this referred to in the past as “auth guarding” specific content. In this case of our example today, we want to auth guard react-router routes. There are a couple of different ways… Read more »