Filter an Array of Objects by Multiple Properties in TypeScript

Filter an array of objects by multiple properties in TypeScript: Command Prompt output of AND, OR and mixed conditions on orders

To filter an array of objects by multiple properties in TypeScript, combine the tests inside one predicate: orders.filter(o => o.status === “shipped” && o.city === “Austin”) for “all of these”, and || for “any of these”. That covers two fixed conditions. Real screens need more: several selected values for the same field, ranges, a search … Read more >>

React: Cannot Update a Component While Rendering a Different Component

React warning cannot update a component while rendering a different component, shown in the browser with the real console text

React prints this warning when one component changes another component’s state while it is rendering. Depending on your React version the text is either “Cannot update a component (Parent) while rendering a different component (Child)” or the older “Cannot update a component from inside the function body of a different component”. Both mean the same … 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 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 >>

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 Use react-vertical-timeline-component in React

React vertical timeline component: two timeline cards with blue numbered icons rendered by react-vertical-timeline-component

react-vertical-timeline-component renders a vertical timeline in React: a centre line with cards alternating left and right, each with a date and an icon. You install it, import its stylesheet, and put a <VerticalTimelineElement> inside a <VerticalTimeline> for every event. This guide builds one step by step, with a screenshot of what each version actually renders, … Read more >>

Python / vs //: True Division and Floor Division

Python division operators: Command Prompt output comparing 7 / 2, 7 // 2 and 7 % 2 and the types they return

Python has two division operators. / is true division and always returns a float, so 7 / 2 is 3.5 and even 8 / 4 is 2.0. // is floor division: it divides and then rounds down, so 7 // 2 is 3. The difference that catches people out is negative numbers, where -7 // … Read more >>

How to Repeat Code, Functions and Values in Python

Repeat in Python: Command Prompt output of a for loop repeating a line three times and a string and list repeated with the star operator

Python has no built-in repeat() function, and what you need depends on what you are repeating. To repeat code a fixed number of times, use for _ in range(n). To repeat it until something happens, use while True with a break, because Python has no repeat-until loop. To repeat a value, multiply it: “ab” * … Read more >>

React Date Picker Component: A Practical Guide

React date picker component: the react-datepicker calendar open below a delivery date field in a React 19 app

A React date picker component gives users a calendar to choose a date from instead of a free-text field. You have two realistic options: the browser’s own <input type=”date”>, which costs nothing and looks different in every browser, or the react-datepicker library, which is the one most projects mean when they say “React date picker”. … Read more >>

Python ceil() Function: How to Round Numbers Up

The ceil function in Python: Command Prompt output of math.ceil rounding 2.1, 2.9 and -2.8 and returning an int

The Python ceil() function rounds a number up to the nearest whole number. It lives in the math module, so you call it as math.ceil(x) after import math: math.ceil(2.1) gives 3, and math.ceil(-2.8) gives -2, because up means towards positive infinity. It always returns an int, never a float. This guide covers the ceiling function … Read more >>