
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
react-file-viewer-v2
Advanced tools
Extendable file viewer for web
react-file-viewer-v2 is a small package for viewing files on the web inspired by react-file-viewer
npm install --save react-file-viewer-v2
There is one main React component, FileViewer
, that takes the following props:
fileType
string: type of resource to be shown (one of the supported file
formats, eg 'png'
). Passing in an unsupported file type will result in displaying
an unsupported file type
message (or a custom component).
file
blob: Blob of the resource to be shown by the FileViewer.
unsupportedComponent
react element [optional]: A component to render in case
the file format is not supported.
import React, { Component } from 'react'
import { FileViewer } from 'react-file-viewer-v2'
class Example extends Component {
render() {
return <FileViewer
file={pdf}
fileType="pdf"
/>
}
}
If you are on React v17, you may receive an error like below: Module not found: Error: Can't resolve 'react/jsx-runtime' in '\node_modules\react-file-viewer-v2\dist\components\FileViewer' Did you mean 'jsx-runtime.js'?
You can resolve this by modifying your webpack config as below:
config.resolve.alias= {
...config.resolve.alias,
"react/jsx-dev-runtime": "react/jsx-dev-runtime.js",
"react/jsx-runtime": "react/jsx-runtime.js"
}
MIT © javier-mora
FAQs
Extendable file viewer for web
The npm package react-file-viewer-v2 receives a total of 57 weekly downloads. As such, react-file-viewer-v2 popularity was classified as not popular.
We found that react-file-viewer-v2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.