diff --git a/demo/components/FileInput.tsx b/demo/components/FileInput.tsx index a0ead58e..7ea8d6ff 100644 --- a/demo/components/FileInput.tsx +++ b/demo/components/FileInput.tsx @@ -1,6 +1,6 @@ import * as yaml from 'js-yaml'; import * as React from 'react'; -import { RefObject, useRef } from 'react'; +import { ChangeEvent, RefObject, useRef } from 'react'; import styled from '../../src/styled-components'; const Button = styled.button` @@ -23,23 +23,23 @@ const Button = styled.button` } `; -const FileInput = (props: { onUpload }) => { +function FileInput(props: { onUpload }) { const hiddenFileInput: RefObject = useRef(null); - function handleClick() { + const handleClick = () => { if (hiddenFileInput && hiddenFileInput.current) { hiddenFileInput.current.click(); } - } + }; - function uploadFile(event) { - const file = event.target.files[0]; + const uploadFile = (event: ChangeEvent) => { + const file = (event.target as HTMLInputElement).files![0]; const reader = new FileReader(); reader.onload = () => { props.onUpload(yaml.load(reader.result)); }; reader.readAsText(file); - } + }; return ( @@ -47,6 +47,6 @@ const FileInput = (props: { onUpload }) => { ); -}; +} export default FileInput;