See also:
Topic

React

JavaScript library
4/17/2020

Built-in React hooks

The list of built-in React hooks.

React 16 introduced hooks, a new way of using stateful features in React components. React both has built-in hooks and provides a way to write custom hooks.

The following table summarizes the built-in React hooks...

Read more
4/4/2020

Declaring custom JSX/HTML attributes in TypeScript

How to specify non-standard JSX/HTML attributes in TypeScript?

Those who switched to TypeScript may experience problems with non-standard JSX/HTML props/attributes. React's type definition file (@types/react/index.d.ts) only includes standard HTML and React elements and props/attributes.

Consider, for example, that you need to allow the banana prop of type string on the <img> element.

Read more
12/13/2019

Multi-<select> in React

How to implement a controlled multi-<select> in React?

Unlike the regular <select>, multi-<select> has more complex onChange logic:

type Value = any

type MultiSelectProps = {
    options: {
        label: string
        value: Value
    }[]
    values: Value[]
    onChange: (values: Value[]) => void
}
Read more
10/7/2019

<select> in React

How to implement a controlled <select> in React?

This is an example of a controlled <select> implementation in React using the JSX syntax:

import React from 'react';

type Value = any

type SelectProps = {
    options: {
        label: string
        value: Value
    }[]
    value: Value
    onChange: (value: Value) => void
}
Read more