From b927a04977d0aa889e49e57c7b10b9741f70309a Mon Sep 17 00:00:00 2001 From: Petra Jaros Date: Fri, 30 Aug 2024 11:25:38 -0400 Subject: [PATCH 1/3] Display Uploader error in console, as promised --- examples/react/components/src/Uploader.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/react/components/src/Uploader.tsx b/examples/react/components/src/Uploader.tsx index 8ae8f1fd..b84837a0 100644 --- a/examples/react/components/src/Uploader.tsx +++ b/examples/react/components/src/Uploader.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode } from 'react' +import React, { ReactNode, useEffect } from 'react' import { Uploader, useUploader, UploadStatus, CARMetadata, UploadProgress, AnyLink } from '@w3ui/react' import { UploadLoader } from './Loader' @@ -30,6 +30,12 @@ function Uploading ({ file, files, storedDAGShards, uploadProgress }: UploadingP } function Errored ({ error }: { error?: Error }): ReactNode { + useEffect(() => { + if (error) { + console.error("Uploader Error:", error) + } + }, [error]) + return (

@@ -136,7 +142,7 @@ export function UploaderForm ({ multiple, allowDirectory }: UploaderFormProps): return (
- + {hasFile ? '' : Drag files or Click to Browse} From 5e72c0ebe72f47f8105eb29e6b56ad87448cc14c Mon Sep 17 00:00:00 2001 From: Petra Jaros Date: Tue, 3 Sep 2024 14:31:53 -0400 Subject: [PATCH 2/3] Include tsconfigs in examples Also include in TS `references`, which eventually means ESLint will pick them up on its own, once we upgrade our lint stack. --- eslint.packages.js | 2 +- tsconfig.json | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/eslint.packages.js b/eslint.packages.js index 90e1ab56..e915efbc 100644 --- a/eslint.packages.js +++ b/eslint.packages.js @@ -1,7 +1,7 @@ module.exports = { extends: ['./node_modules/hd-scripts/eslint/ts.js'], parserOptions: { - project: ['./tsconfig.json', 'packages/*/tsconfig.json'], + project: ['./tsconfig.json', 'packages/*/tsconfig.json', 'examples/*/*/tsconfig.json'], ecmaFeatures: { jsx: true, }, diff --git a/tsconfig.json b/tsconfig.json index 2ac4ab77..9fbb423f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,9 @@ }, { "path": "packages/react" + }, + { + "path": "examples/react/components" } ] } From 33c31d924c1897ebd214c5eb4b6b50a8d5c0553b Mon Sep 17 00:00:00 2001 From: Petra Jaros Date: Tue, 3 Sep 2024 14:33:51 -0400 Subject: [PATCH 3/3] Address linter We've disabled `no-console` elsewhere for one-offs, and this seems akin to that. --- examples/react/components/src/Uploader.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/react/components/src/Uploader.tsx b/examples/react/components/src/Uploader.tsx index b84837a0..156dd7c8 100644 --- a/examples/react/components/src/Uploader.tsx +++ b/examples/react/components/src/Uploader.tsx @@ -31,11 +31,12 @@ function Uploading ({ file, files, storedDAGShards, uploadProgress }: UploadingP function Errored ({ error }: { error?: Error }): ReactNode { useEffect(() => { - if (error) { - console.error("Uploader Error:", error) + if (error != null) { + // eslint-disable-next-line no-console + console.error('Uploader Error:', error) } }, [error]) - + return (