diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/Examples.tsx index 85555e17f28..2b3ad520a00 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/Examples.tsx @@ -24,21 +24,10 @@ export function createMockFile(name: string, size: number, type: string) { return file } -const useMockFiles = (setFiles, extend) => { - React.useEffect(() => { - setFiles([ - { - file: createMockFile('fileName.png', 123, 'image/png'), - ...extend, - }, - ]) - }, []) -} - export const UploadPrefilledFileList = () => ( {() => { const Component = () => { @@ -48,7 +37,14 @@ export const UploadPrefilledFileList = () => ( console.log('files', files) } - useMockFiles(setFiles, { errorMessage: 'This is no real file!' }) + React.useEffect(() => { + setFiles([ + { + file: createMockFile('fileName.png', 123, 'image/png'), + errorMessage: 'This is no real file!', + }, + ]) + }, []) return } @@ -157,14 +153,21 @@ export const UploadRemoveFile = () => ( export const UploadIsLoading = () => ( {() => { const Component = () => { const { files, setFiles } = Upload.useUpload('upload-is-loading') - useMockFiles(setFiles, { isLoading: true }) + React.useEffect(() => { + setFiles([ + { + file: createMockFile('fileName.png', 123, 'image/png'), + isLoading: true, + }, + ]) + }, []) return ( <>