Skip to content

Commit ca6e786

Browse files
committed
add js-docs for useCSVReader hook usage with generic types
1 parent 093deb5 commit ca6e786

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/useCSVReader.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,28 @@ function useCSVReaderComponent<
642642
return CSVReader;
643643
}
644644

645+
/**
646+
* A React hook to use the CSVReader component.
647+
* @returns The CSVReader component.
648+
*
649+
* @template T - The type of the parsed CSV file data result, where each key
650+
* represents a column in the CSV file and each value represents the data type.
651+
* @template E - The type of the HTML element used for the input. Can be
652+
* HTMLDivElement or HTMLButtonElement. Defaults to HTMLDivElement.
653+
*
654+
* @example HTMLDivElement as the input element
655+
* ```tsx
656+
* import { useCSVReader } from 'react-papaparse';
657+
* const { CSVReader } = useCSVReader();
658+
* ```
659+
* @example HTMLButtonElement as the input element
660+
* ```tsx
661+
* import { useCSVReader } from 'react-papaparse';
662+
* const { CSVReader } = useCSVReader<void, HTMLButtonElement>();
663+
* ```
664+
*
665+
* @see {@link https://react-papaparse.js.org/docs#local-files Usage with Local Files}
666+
*/
645667
export function useCSVReader<
646668
T = void,
647669
E extends HTMLDivElement | HTMLButtonElement = HTMLDivElement

0 commit comments

Comments
 (0)