TypeScript definitions for React, the popular JavaScript library for building user interfaces
80
Build a reusable custom input component that exposes its underlying DOM element to parent components, allowing them to programmatically control focus and selection.
Create a CustomInput component that:
focus() and select()The component should:
label prop (string) to display above the inputfocus() is called on the ref, the input element receives focus @testselect() is called on the ref, the input text is selected @test@generates
import React from 'react';
interface CustomInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
label: string;
}
declare const CustomInput: React.ForwardRefExoticComponent<
CustomInputProps & React.RefAttributes<HTMLInputElement>
>;
export default CustomInput;Provides the forwardRef API and component types for building reusable components with ref forwarding.
Install with Tessl CLI
npx tessl i tessl/npm-types--reactdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10