Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-file-preview-latest

syadav2141.6kISC1.0.3

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

reactjs, js, file preview, image preview, preview, pdf preview, text preview

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

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

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