react-file-viewer-v2
Advanced tools
Comparing version
{ | ||
"name": "react-file-viewer-v2", | ||
"private": false, | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Extendable file viewer for web", | ||
@@ -6,0 +6,0 @@ "author": "javier-mora", |
@@ -1,30 +0,51 @@ | ||
# React + TypeScript + Vite | ||
# react-file-viewer-v2 | ||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
> Extendable file viewer for web | ||
Currently, two official plugins are available: | ||
[](https://www.npmjs.com/package/react-file-viewer-v2) [](https://standardjs.com) | ||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
**react-file-viewer-v2** is a small package for viewing files on the web inspired by [react-file-viewer](https://github.com/plangrid/react-file-viewer) | ||
## Expanding the ESLint configuration | ||
## Install | ||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
```bash | ||
npm install --save react-file-viewer-v2 | ||
``` | ||
- Configure the top-level `parserOptions` property like this: | ||
## Supported file formats: | ||
```js | ||
export default { | ||
// other rules... | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
- Images: png, jpeg, gif | ||
- docx | ||
- Video: mp4, webm | ||
- Audio: mp3 | ||
## Usage | ||
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). | ||
`filePath` string: the url 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. | ||
```tsx | ||
import React, { Component } from 'react' | ||
import { FileViewer } from 'react-file-viewer-v2' | ||
class Example extends Component { | ||
render() { | ||
return <FileViewer | ||
fileType="pdf" | ||
filePath={pdf} | ||
/> | ||
} | ||
} | ||
``` | ||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list | ||
## License | ||
MIT © [javier-mora](https://github.com/javier-mora) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
258983
0.04%52
67.74%1
-50%