You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Existence in Javascript (but written in Typescript)
A simple series of utility to check value existence.
function itExists(it: unknown): boolean {
if (!hasValue(it)) return false;
else if (Array.isArray(it)) return isArrNotEmpty(it);
else if (typeof it === 'object') return isObjNotEmpty(it!);
else return true;
How to gracefully handle runtime and http errors in react using axios, react query and react router dom 6
Error Handling
This error handling system differentiates between unexpected runtime errors and anticipated HTTP errors, managing them globally through an Error Boundary (provided by Reacr Router Dom) and locally, at component level, via React Query.
Keeping your project's dependencies updated is crucial for security and efficiency. In this guide, we'll explore how to automate the updating of minor dependencies using GitHub Actions and Husky hooks.
Automating dependency updates ensures that your project stays current with the latest patches and improvements without manual oversight. Using GitHub Actions, we can check for and apply these updates regularly. Additionally, with Husky, we can ensure that any changes in dependency files trigger necessary installations post-merge.
Prerequisites
Before setting up the automation, you need to prepare your project with a couple of steps:
react custom hook implementing a queryparams store
Queryparams Store Hook
useQueryParamsStore is a custom React hook that stores and retrieves data within URL query parameters.
This functionality not only maintains data across page refreshes but also enables users to share a state with others preventing sensitive information from being exposed in plain text within the browser's URL bar.
In this guide, we'll present a handy TypeScript utility that can streamline your error handling process. This utility provides a simple and clear way to encapsulate potential errors and handle them gracefully.
Snippets are based on no-try npm package (link below).
TypeScript Snippet: useTry and useTryAsync
The TypeScript utility is composed of two main functions, useTry and useTryAsync.
Full implementation of an Analytics System in Angular using Google Tag Manager with Partytown Workers
How to add Analytics in Angular w/ GTM & Partytown
In this article, we will explore how to integrate analytics into an Angular application using Google Tag Manager (GTM) and Partytown. We will cover the necessary typings, a service for handling analytics events, a directive for tracking button clicks, an error interceptor for logging HTTP errors, and form tracking. Let's dive into each component.
As developers, we strive to write robust and error-free code.
One of the ways to achieve this is by leveraging TypeScript's powerful type inference system.
This code snippet demonstrates how we can infer TypeScript types from JavaScript variables using the as const syntax.
By using the as const syntax, we can tell TypeScript that the variable's values are constant and should not be mutated.
This allows TypeScript to infer literal types for the values, making our code more type-safe and reducing the likelihood of runtime errors.