Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mebtte/react-image-viewer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mebtte/react-image-viewer

React Component that view a image.

  • 0.5.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-image-viewer

React Component that view a image. See it online.

Install

# ImageViewer requirement
npm install --save react prop-types
npm install --save @mebtte/react-image-viewer

Usage

As Component

import React from 'react';

import ImageViewer from '@mebtte/react-image-viewer';

class Demo extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      open: false,
      src: 'https://mebtte.com/resource/wallpaper',
    };
  }

  openImageViewer = () => this.setState({ open: true })

  closeImageViewer = () => this.setState({ open: false })

  render() {
    const { open, src } = this.state;
    return (
      <div>
        <button type="button" onClick={this.openImageViewer}>
          open
        </button>
        <ImageViewer
          open={open}
          src={src}
          onClose={this.closeImageViewer}
        />
      </div>
    );
  }
}

export default Demo;

As Function

view(src, [zIndex = 3333]) => Void

Use it as a function to view a image.

  • params

src (String): The src of image.
[zIndex] (Number): The css z-index, default 3333.

  • example
# function depend on `react-dom`, so it do not support `ssr`
npm i --save-dev react-dom
import React from 'react';

import view from '@mebtte/react-image-viewer/view';

const src = 'https://mebtte.com/resource/wallpaper';

class Demo extends React.Component {
  viewImage = () => view(src)

  render() {
    return (
      <button type="button" onClick={this.viewImage}>
        open
      </button>
    );
  }
}

export default Demo;

Props

nametyperequireddefaultdescription
openBooleantrueVisibility.
srcStringtrueThe src of image.
onCloseFunctiontrueThe close event handler.
zIndexNumberfalse3333The z-index css.

Keywords

FAQs

Package last updated on 18 Jul 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc