Categories
Basic TypeScript

Everyday Types

https://www.typescriptlang.org/docs/handbook/2/everyday-types.html

Categories
React

Function rendering in React

https://unicorn-utterances.com/posts/functions-are-killing-react-performance#render-functions

Categories
React

React Router

V5 Dynamic Routing Routing that takes place as your app is rendering, not in a configuration or convention outside of a running app. Primary Components <BrowserRouter> A <Router> that uses the HTML5 history API (pushState, replaceState and the popstate event) to keep your UI in sync with the URL. Container of other <Route>s. <Route> Its most basic responsibility is to render some […]

Categories
JavaScript

Promise

Description A Promise is a proxy for a value not necessarily known when the promise is created.  The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. Instead of callback functions, it allows you to associate handlers with an asynchronous action’s eventual success value or failure reason. This lets asynchronous methods return […]

Categories
React

Controlled and uncontrolled components

Introduction Uncontrolled component: self-control controlled component: parent component passes in value and handles change Example 1: A Uncontrolled Component is one that stores its own state internally, and you query the DOM using a ref to find its current value when you need it. This is a bit more like traditional HTML. A Controlled Component is one that takes its current […]

Categories
TypeScript

Type narrowing

In TypeScript, type narrowing is the removal of types from a union. To narrow a variable to a specific type, we use the type guard.  typeof Return values: Another check for array: Array.isArray() “in” operator JavaScript has an operator for determining if an object has a property with a name: the in operator. instanceof Type Predicates To define […]

Categories
HTML

time Element

Introduction The <time> HTML element represents a specific period in time. It may include the datetime attribute to translate dates into machine-readable format, allowing for better search engine results or custom features such as reminders. Attributes datetime

Categories
React

Refresh/Reload Page

Reload Refresh Refs Refresh method

Categories
React

React Rendering

It Always Re-renders By default, when the state of the component changes, this component and all its children re-render.  But React updates a text node only when there’s visual change. “Rendering” of react component is not the same with “updating the DOM”. How to Prevent Re-renders memo() Wrapping a component with memo prevents the entire subtree of this component […]

Categories
css HTML

Table

Table with max-height Prevent Row Break Between Pages Ref Table with max-height – solution 1 Table with max-height – solution 2