Fix type error in FileUploader (#1280)

Summary:
Introduced in #1277.

Test Plan:
Run `yarn start` and visit <http://localhost:8080/test/FileUploader/>.
Conduct the test plan as specified on that page.

wchargin-branch: fileuploader-target
This commit is contained in:
William Chargin 2019-08-13 09:20:54 -07:00 committed by Dandelion Mané
parent 95b8974f6a
commit 607a6d426d
1 changed files with 5 additions and 2 deletions

View File

@ -24,8 +24,11 @@ export class FileUploader extends React.Component<Props> {
const onUpload = (e) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
const jsonString = e.target.result;
reader.onload = () => {
const jsonString = reader.result;
if (typeof jsonString !== "string") {
throw new Error("Unexpected: jsonString is not string");
}
const json = JSON.parse(jsonString);
this.props.onUpload(json);
};