From 607a6d426d36499ce268ce9b5bba12ec2436d402 Mon Sep 17 00:00:00 2001 From: William Chargin Date: Tue, 13 Aug 2019 09:20:54 -0700 Subject: [PATCH] Fix type error in FileUploader (#1280) Summary: Introduced in #1277. Test Plan: Run `yarn start` and visit . Conduct the test plan as specified on that page. wchargin-branch: fileuploader-target --- src/util/FileUploader.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/FileUploader.js b/src/util/FileUploader.js index c0ca96b..90050ec 100644 --- a/src/util/FileUploader.js +++ b/src/util/FileUploader.js @@ -24,8 +24,11 @@ export class FileUploader extends React.Component { 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); };