-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CU-86b06xn8q] feat(uploader): enhanced file preview with react-file-viewer #246
[CU-86b06xn8q] feat(uploader): enhanced file preview with react-file-viewer #246
Conversation
- Added support for previewing multiple file types (PDF, DOCX, XLSX, etc.) - Implemented `react-file-viewer` for better file preview capabilities - Maintained fallback to FileIcon component when preview fails OTHER CHANGES - Resolved React version mismatch (16.14.0 -> 18.2.0) to fix hook errors in Storybook - Added VSCode workspace folder to `.gitignore` BREAKING CHANGE: New dependency `react-file-viewer` is required
- Added hover effect with background color change and shadow elevation - Implemented cursor pointer for clickable file previews - Added active state for click feedback - Enhanced dark mode hover states - Maintained consistent hover behaviour across mini and full preview modes
- Added modal-based DOCX preview to prevent interference between multiple previews - Created FileWithId interface and shared type definitions - Fixed file ID generation and management - Added proper cleanup for object URLs - Ensured consistent key generation for previews BREAKING CHANGE: File state type is now FileWithId[] instead of File[]
- Replaced DOCX-specific preview with universal file preview component - Added modal preview support for all file types - Fixed file name truncation in preview cards
- swapped and for uuid - removed duplicated returned error element
const objectUrl = useMemo(() => { | ||
const url = URL.createObjectURL(file) | ||
objectUrls.current.push(url) | ||
return url | ||
}, [file]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could lead the url being added multiple times -> memory leaks if the useMemo is triggered multiple times (can happen alot with javascript.)
make sure the URL isn't already in the list before adding it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @MedAmine1212, done
- removed `console.log` statements
react-file-viewer
for better file preview capabilitiesOTHER CHANGES
.gitignore
BREAKING CHANGE: New dependency
react-file-viewer
is required