You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-file-viewer-v2

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-file-viewer-v2 - npm Package Compare versions

Comparing version

to
2.0.1

2

package.json
{
"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:
[![NPM](https://img.shields.io/npm/v/react-file-viewer-v2.svg)](https://www.npmjs.com/package/react-file-viewer-v2) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](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
- pdf
- 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)