File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
src/components/FileOrganizer Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,13 @@ const Template: FC<TemplateProps> = ({
35
35
customSizedThumbnail,
36
36
} ) => {
37
37
// This is the index organizing function.
38
- const [ files , setFiles ] = useState < FakeFile [ ] > ( [ ] ) ;
38
+ const [ files , setFiles ] = useState < FakeFile [ ] > ( ( ) => {
39
+ const newFiles = [ ] ;
40
+ for ( let index = 0 ; index < numFiles ; index ++ ) {
41
+ newFiles . push ( createFile ( index ) ) ;
42
+ }
43
+ return newFiles ;
44
+ } ) ;
39
45
const handleOnMove = useCallback < NonNullable < FileOrganizerProps < FakeFile > [ 'onMove' ] > > ( ( fromIndex , toIndex ) => {
40
46
setFiles ( ( prev ) => {
41
47
if ( toIndex < 0 || toIndex >= prev . length ) return prev ;
Original file line number Diff line number Diff line change @@ -183,8 +183,8 @@ export function FileOrganizer<F extends ObjectWithId>({
183
183
184
184
// Update size when getWidth ref changes (when hasFiles changes).
185
185
useEffect ( ( ) => {
186
- if ( thumbnailSize ) setSize ( thumbnailSize ) ;
187
- if ( files . length === 0 ) setSize ( defaultSize ) ;
186
+ if ( thumbnailSize ) return setSize ( thumbnailSize ) ;
187
+ if ( files . length === 0 ) return setSize ( defaultSize ) ;
188
188
setSize ( ( prev ) => {
189
189
const { width, height } = getSize ( ) ;
190
190
if ( prev . width === width && prev . height === height ) return prev ;
You can’t perform that action at this time.
0 commit comments