# react-file-preview-latest

> React component to render and preview images, pdf and text files via file object or web url

Latest version **1.0.3** (published 2021-07-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-file-preview-latest
pnpm add react-file-preview-latest
yarn add react-file-preview-latest
bun add react-file-preview-latest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-07-21 |
| First published | 2021-07-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 191.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Santosh Yadav |
| Maintainers | syadav214 |
| Keywords | reactjs, js, file preview, image preview, preview, pdf preview, text preview |

## Links

- npm: https://www.npmjs.com/package/react-file-preview-latest
- Repository: https://github.com/syadav214/react-file-preview-latest
- Homepage: https://github.com/syadav214/react-file-preview-latest#readme
- Issues: https://github.com/syadav214/react-file-preview-latest/issues
- npm.io page: https://npm.io/package/react-file-preview-latest

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^16.4.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.8.6

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-07-21
- 1.0.2 — 2021-07-21
- 1.0.1 — 2021-07-21
- 1.0.0 — 2021-07-21

## README

# react-file-preview-latest

React component to render and preview images, pdf and text files via file object or web url

## Example

![alt text](file-preview.png)

```jsx
import React, { Component } from "react";
import FilePreview from "react-file-preview-latest";

class App extends Component {
  constructor() {
    super();
    this.state = {
      file: null,
    };
  }
  
  onError = (err) => console.log("Error:", err); // Write your own logic

  render() {
    return (
      <FilePreview
        type={"file"}
        file={this.state.file}
        onError={this.onError}
      />
    );
  }
}

export default App;
```

## Install

```cli
npm install react-file-preview-latest
```

## Props

##### `type`

It can be either `file` or `url`.

---

##### `file`

The file object of input[type="file"] element which needs to be previewed.

---

##### `url`

The url which needs to be previewed.

---

##### `onError`

A callback function to get detailed error.

## License

MIT

---
_Source: https://npm.io/package/react-file-preview-latest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
