
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
react-image-viewer-zoom
Advanced tools
A scalebale image viewer for React.
$ npm install --save react-image-viewer-zoom
import ImageViewer from 'react-image-viewer-zoom'
import 'react-image-viewer-zoom/dist/style.css'
class MyComponent extends React.Component<any, any> {
render() {
const images: any = [
{ src: 'https://unsplash.it/800/300?image=1', title: 'title', content: 'content' },
{ src: 'https://unsplash.it/300/800?image=2', title: 'title', content: 'content' },
{ src: 'https://unsplash.it/1800/300?image=3', title: 'title', content: 'content' },
{ src: 'https://unsplash.it/800/1800?image=4', title: 'title', content: 'content' }
];
return (
<ImageViewer
showPreview={true}
showIndex={true}
prefixCls="mycomponent"
activeIndex={0}
images={images}/>
)
}
}
Implement in a modal
class MyModal extends React.Component<any, any> {
constructor(props: any) {
this.state = {
activeIndex: undefined,
visible: false
}
}
// init active index when open the modal
open(activeIndex? number) {
this.setState({
activeIndex: activeIndex || 0,
visible: true
});
}
render() {
const { activeIndex } = this.state;
return this.state.visible ? (
<div className='my-modal'>
<ImageViewer
showPreview
showIndex
activeIndex={activeIndex}
images={images}/>
</div>
) : null;
}
}
Prop | Type | Required | Default | Details |
---|---|---|---|---|
images | array | yes | The set for the image | |
showIndex | boolean | no | true | Show the index of the current image on toolbar |
showPreview | boolean | no | true | Show bottom Indicators image preview |
activeIndex | number | no | 0 | Specify the active image when init the image viewer |
prefixCls | string | no | null | |
className | string | no | null |
Each image item options props
Prop | Type | Required | Details |
---|---|---|---|
src | string | Yes | The source of the image |
title | string | No | Image title |
content | string | No | Image caption |
tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true
}
}
Set
allowSyntheticDefaultImports
to preventerror TS1192: Module 'react' has no default export
.
FAQs
A React-based image viewer.
The npm package react-image-viewer-zoom receives a total of 16 weekly downloads. As such, react-image-viewer-zoom popularity was classified as not popular.
We found that react-image-viewer-zoom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.