随笔分类 -  React

上一页 1 2 3 4 5 6 ··· 23 下一页
摘要:This is ReactNode: type ReactNode = | ReactElement | string | number | ReactFragment | ReactPortal | boolean | null | undefined This is React.ReactEle 阅读全文
posted @ 2023-08-22 15:37 Zhentiw 阅读(25) 评论(0) 推荐(0) 编辑
摘要:export = React; export as namespace React; declare namespace React { // // React Elements // type ElementType<P = any> = { [K in keyof JSX.IntrinsicEl 阅读全文
posted @ 2023-08-21 15:03 Zhentiw 阅读(91) 评论(0) 推荐(0) 编辑
摘要:import { DependencyList, useMemo, useState } from "react"; import { Equal, Expect } from "../helpers/type-utils"; const useCustomState = <TValue>(init 阅读全文
posted @ 2023-08-21 14:45 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:import { useState } from "react"; import { Equal, Expect } from "../helpers/type-utils"; type UseStateReturnValue<T> = { value: T; set: React.Dispatch 阅读全文
posted @ 2023-08-21 14:39 Zhentiw 阅读(20) 评论(0) 推荐(0) 编辑
摘要:import { useEffect, useState } from "react"; export type Result<T> = | ["loading", undefined?] | ["error", Error] | ["success", T]; export const useDa 阅读全文
posted @ 2023-08-17 15:14 Zhentiw 阅读(7) 评论(0) 推荐(0) 编辑
摘要:import React from "react"; import { Equal, Expect } from "../helpers/type-utils"; const createRequiredContext = <T extends any>() => { const context = 阅读全文
posted @ 2023-08-16 20:20 Zhentiw 阅读(9) 评论(0) 推荐(0) 编辑
摘要:// Problem import { useState } from "react"; import { Equal, Expect } from "../helpers/type-utils"; export const useId = (defaultId: string) => { cons 阅读全文
posted @ 2023-08-16 19:48 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:import { Equal, Expect } from "../helpers/type-utils"; interface Button<T> { value: T; label: string; } interface ButtonGroupProps<T> { buttons: Butto 阅读全文
posted @ 2023-08-12 16:49 Zhentiw 阅读(12) 评论(0) 推荐(0) 编辑
摘要:import { ReactNode } from "react"; import { Equal, Expect } from "../helpers/type-utils"; interface TableProps<T> { rows: T[]; renderRow: (row: T) => 阅读全文
posted @ 2023-08-12 16:19 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:interface TableProps<T> { rows: T[]; renderRow: (row: T) => ReactNode; } export class Table<T> extends React.Component<TableProps<T>> { render(): Reac 阅读全文
posted @ 2023-08-12 16:08 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:export const Table = <T>(props: TableProps<T>) => { return ( <table> <tbody> {props.rows.map((row) => ( <tr>{props.renderRow(row)}</tr> ))} </tbody> < 阅读全文
posted @ 2023-08-11 15:01 Zhentiw 阅读(7) 评论(0) 推荐(0) 编辑
摘要:import { ComponentProps } from "react"; import { Equal, Expect } from "../helpers/type-utils"; const buttonProps = { type: "button", // @ts-expect-err 阅读全文
posted @ 2023-08-07 15:02 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要:const presetSizes = { xs: "0.5rem", sm: "1rem", }; type Size = keyof typeof presetSizes; //type LooseSize = Size | string; // the result will be strin 阅读全文
posted @ 2023-08-04 19:44 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:import React, { forwardRef } from "react"; // Declare a type that works with generic components type FixedForwardRef = <T, P = {}>( render: (props: P, 阅读全文
posted @ 2023-08-01 14:11 Zhentiw 阅读(54) 评论(0) 推荐(0) 编辑
摘要:React set the ref to null in runtime. It is a limitation now for react. import { useRef } from 'react'; export const Component = () => { const ref = u 阅读全文
posted @ 2023-05-24 15:11 Zhentiw 阅读(16) 评论(0) 推荐(0) 编辑
摘要:// Imagine NavBar is an external library! export const NavBar = (props: { title: string; links: string[]; children: React.ReactNode; }) => { return <d 阅读全文
posted @ 2023-05-22 14:11 Zhentiw 阅读(12) 评论(0) 推荐(0) 编辑
摘要:Using Omit import { ComponentProps } from 'react'; import { Equal, Expect } from '../helpers/type-utils'; export const Input = ( props: Omit<Component 阅读全文
posted @ 2023-05-22 13:58 Zhentiw 阅读(36) 评论(0) 推荐(0) 编辑
摘要:Relevant for components that accept other React components as props. export declare interface AppProps { children?: React.ReactNode; // best, accepts 阅读全文
posted @ 2023-05-22 13:24 Zhentiw 阅读(16) 评论(0) 推荐(0) 编辑
摘要:Blog: https://www.totaltypescript.com/react-component-props-type-helper Get any Prop type from html element: import { ComponentProps } from "react"; t 阅读全文
posted @ 2023-05-07 16:04 Zhentiw 阅读(68) 评论(0) 推荐(0) 编辑
摘要:ProductCard component import './ProductCard.css'; import { ReactNode } from 'react'; import * as React from 'react'; import ProductCardContext from '. 阅读全文
posted @ 2023-03-30 00:58 Zhentiw 阅读(16) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 23 下一页
点击右上角即可分享
微信分享提示