React Gantt Chart Component: Library and Custom Build

React Gantt chart component: three dependent tasks rendered by gantt-task-react with a task list and week columns

A Gantt chart shows tasks as bars on a timeline, with dependencies between them. In React you have two sensible routes: install a library, or build a small chart yourself with CSS grid. This guide does both. The library part uses gantt-task-react, which is free, MIT-licensed, and gives you dependency arrows, drag and resize, progress … Read more >>

React Hooks in Class Components: What Works Instead

React hooks in class components: the browser showing the error React throws when useState is called inside a class render

You cannot use React hooks inside a class component. Hooks only work in function components and in custom hooks, and React throws an error if you call one from a class. There are three practical ways round it: wrap the class in a small function component that calls the hook and passes the values down … Read more >>

React Error Boundaries with Functional Components

React error boundary with functional components: the browser showing a fallback message while the rest of the dashboard keeps working

To use a React error boundary with functional components, you still need one class: React has no hook that catches rendering errors, so the boundary itself has to be a class component even in an app made entirely of function components. You write that class once and wrap your function components in it. The usual … Read more >>

Arrays of Objects in TypeScript: Declare, Type and Use Them

Arrays of objects in TypeScript: Command Prompt output of a Product interface used to type an array and map over it

An array of objects in TypeScript is declared by describing one object and adding []: const products: Product[] = […], where Product is an interface or a type alias. Array<Product> means the same thing. Once the array is typed, the compiler checks every property you write and every property you read, which is the whole … Read more >>

How to Filter an Array of Objects in TypeScript

Filter an array of objects in TypeScript: Command Prompt output of filtering orders by status, total and city

To filter an array of objects in TypeScript, pass filter() a function that tests a property: orders.filter(order => order.status === “shipped”). You get a new array of the same object type, the original is untouched, and the compiler checks every property name as you type it. This guide covers filtering by one property and by … Read more >>

How to Sort Arrays in TypeScript

Sort arrays in TypeScript: Command Prompt output of sort() with and without a compare function on numbers and strings

To sort an array in TypeScript, call sort() with a compare function: numbers.sort((a, b) => a – b) for numbers and names.sort((a, b) => a.localeCompare(b)) for text. Swap a and b for descending order. Without a compare function sort() turns every element into a string first, which is why [100, 25, 9, 1000, 3] comes … Read more >>

How to Filter Arrays in TypeScript

Filter arrays in TypeScript: Command Prompt output of filter() selecting numbers above a limit and city names beginning with A

To filter an array in TypeScript, call filter() with a function that returns true for the elements you want to keep: temperatures.filter(temp => temp > 80). It returns a new array and never changes the original, so the result of filtering a number[] is a number[]. The one place TypeScript surprises people is removing undefined … Read more >>

Python bin() Function: Convert Integers to Binary

bin() Function Python

When I build small Python automation scripts, I often need to inspect values at the binary level. This happens when I work with permission flags, device status codes, color values, or compact settings stored as a single number. A decimal value like 13 is easy to read, but 0b1101 shows exactly which individual bits are switched on. Python makes … Read more >>

Python ascii() Function: A Practical Guide With Examples

ascii() Function Python

A customer-name cleanup script looks fine until someone enters “José”, “Megan O’Connor”, or an emoji in a notes field. When you print the value, terminals, log files, and API payloads do not always show those characters the same way. I have used Python’s ascii() function most often while debugging text pulled from CSV files, APIs, and form … Read more >>