react-barcode-reader
react-barcode-reader copied to clipboard
Module for TypeScript
module declaration for react-barcode-reader is missing. To be able to use in TYPESCRIPT
@andresramirez82 I needed this for my project too so I just wrote them up. Feel free to snag these and put them in a types.d.ts file
declare module 'react-barcode-reader' {
export interface BarcodeReaderProps {
onScan?: (barcode: string) => void;
onError?: (barcode: string) => void;
onReceive?: (char: string) => void;
onKeyDetect?: (char: string) => void;
timeBeforeScanTest?: number;
avgTimeByChar?: number;
minLength?: number;
endChar?: number[];
startChar?: number[];
scanButtonKeyCode?: number;
scanButtonLongPressThreshold?: number;
onScanButtonLongPressed?: () => void;
stopPropagation?: boolean;
preventDefault?: boolean;
testCode?: string;
}
declare class BarcodeReader extends React.Component<
BarcodeReaderProps,
any
> {}
export default BarcodeReader;
}
Thanks for writing it up. A minor edit to the above. The onError prop is a function with two arguments. The above line:
onError?: (barcode: string) => void;
should be:
onError?: (barcode: string, message: string) => void;