Journal

A collection of thoughts on engineering, design patterns, and building sustainable digital experiences.

Simplifying Async Error Handling in TypeScript

4 min read

If you've worked with asynchronous code in TypeScript for any length of time, you'll know that error handling can get messy fast. Between nested try-catch blocks and repetitive error-handling logic, it doesn't take long before your codebase starts feeling cluttered. That's why I've found myself leaning toward a more elegant solution — the `tryCatch` helper function. This little utility is inspired by Go's error-handling approach and wraps your async functions in a way that simplifies error management, making your code more readable and maintainable.

Best Practices for Using React Context

4 min read

React Context is a powerful feature that allows components to share state without prop drilling. It's particularly useful for managing global state, theme preferences, user authentication, and more. However, like any tool, it's important to use React Context effectively to ensure maintainable and organized code. In this post, we'll delve into best practices for using React Context, and why exporting your `useContext` logic to a custom hook is a wise decision.

Written with clarity in mind.

Thanks for the coffee!

Every cup fuels another line of thoughtful code.

× 1