Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 9x 2x 2x 2x 1x 1x 1x 1x 1x 1x 2x 9x | import React, { FC, PropsWithChildren, useEffect, memo } from 'react'; import { useStore } from './store'; export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> { keyname?: string; /** * Used to define the name of form controls * @deprecated use `name` */ rename?: string; /** Can be shown or hidden with controls */ visible?: boolean; /** "index" refers to the use of indexes to control the order of controls, which can provide more flexible API encapsulation. */ index?: number; } export const Input: FC<PropsWithChildren<InputProps>> = memo((props) => { const { fields = {}, extra = {}, $$index = {}, dispatch } = useStore(); const { rename, keyname, visible = true, children, ...elmProps } = props; useEffect(() => { Eif (keyname || elmProps.name) { const key = (keyname || elmProps.name) as string; delete $$index[key]; delete fields[key]; delete extra[key]; dispatch({ $$index: { ...$$index, [key]: elmProps.index || 0 }, extra: { ...extra, [key]: children || null, }, fields: { ...fields, [key]: visible ? <input {...elmProps} name={rename || elmProps.name} /> : null, }, }); } }, [props]); return null; }); Input.displayName = 'Login.Input'; |