@types/react-file-reader-input
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

Installation

npm install --save @types/react-file-reader-input

Summary

This package contains type definitions for react-file-reader-input (https://github.com/ngokevin/react-file-reader-input).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-file-reader-input.

index.d.ts

import * as React from "react";

declare class FileInput extends React.Component<FileInput.Props> {
}

declare namespace FileInput {
    type Format = "buffer" | "binary" | "url" | "text";
    type Result = [ProgressEvent, File];

    interface Props extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
        /**
         * what format the `FileReader` should read the file as
         * (i.e., `'buffer'`, `'binary'`, `'url'`, `'text'`).
         *
         * Defaults to `'url'`.
         */
        as?: Format | undefined;

        /**
         * Callback function called when the files are chosen by the user.
         *
         * Results will be an array of arrays, the size of which depending
         * on how many files were selected.
         *
         * Each result will be an array of two items:
         *
         * `progressEvent`: `result[0]` is a `ProgressEvent` object.
         * You can retrieve the raw results at `progressEvent.target.result`
         * among other things.
         *
         * `file`: `result[1]` is a `File` object. You can retrieve the file name
         * at file.name among other things.
         *
         * @param event The event that triggered file changes
         * @param results The array of files
         */
        onChange(event: React.ChangeEvent<HTMLInputElement>, results: Result[]): void;
    }
}

export = FileInput;

Additional Details

  • Last updated: Tue, 07 Nov 2023 09:09:39 GMT
  • Dependencies: @types/react

Credits

These definitions were written by Dmitry Rogozhny, Ali Taheri, and bjoluc.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/react-file-reader-input

Weekly Downloads

493

Version

2.0.4

License

MIT

Unpacked Size

5.94 kB

Total Files

5

Last publish

Collaborators

  • types