Software Engineer @ TechCorp Inc.
Get advanced analytics, unlimited projects, and exclusive features
Starting at $9/month
A collection of TypeScript utility types that will make your code more type-safe and maintainable.
// Creating a conditional type for API responses
type ApiResponse<T> = {
data: T
success: true
message: string
} | {
data: null
success: false
error: string
}
// Usage example
const handleResponse = <T>(response: ApiResponse<T>) => {
if (response.success) {
return response.data // Type is T
} else {
throw new Error(response.error)
}
}Been thinking about the evolution of React state management. From Redux being the go-to solution to now having amazing options like Zustand, Jotai, and Valtio. Each has its place depending on the use case. What's your favorite state management solution in 2024?
Share your thoughts and experiences in the comments below.