Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@wadev12/react-cropper
Advanced tools
Cropperjs as React components
Install via npm
npm install --save react-cropper
You need cropper.css
in your project which is from cropperjs.
Since this project have dependency on cropperjs, it located in /node_modules/react-cropper/node_modules/cropperjs/dist/cropper.css
or node_modules/cropperjs/dist/cropper.css
for npm version 3.0.0
later
import React, {Component} from 'react';
import Cropper from 'react-cropper';
import 'cropperjs/dist/cropper.css'; // see installation section above for versions of NPM older than 3.0.0
// If you choose not to use import, you need to assign Cropper to default
// var Cropper = require('react-cropper').default
class Demo extends Component {
_crop(){
// image in dataUrl
console.log(this.refs.cropper.getCroppedCanvas().toDataURL());
}
render() {
return (
<Cropper
ref='cropper'
src='http://fengyuanchen.github.io/cropper/img/picture.jpg'
style={{height: 400, width: '100%'}}
// Cropper.js options
aspectRatio={16 / 9}
guides={false}
crop={this._crop.bind(this)} />
);
}
}
string
null
<Cropper src='http://fengyuanchen.github.io/cropper/img/picture.jpg' />
string
picture
string
null
https://github.com/fengyuanchen/cropperjs#aspectratio
https://github.com/fengyuanchen/cropperjs#dragmode
https://github.com/fengyuanchen/cropperjs#setdatadata
https://github.com/fengyuanchen/cropperjs#scalexscalex
https://github.com/fengyuanchen/cropperjs#scalexscaley
https://github.com/fengyuanchen/cropperjs#enable
https://github.com/fengyuanchen/cropperjs#disable
https://github.com/fengyuanchen/cropperjs#setcropboxdatadata
https://github.com/fengyuanchen/cropperjs#setcanvasdata
https://github.com/fengyuanchen/cropperjs#zoomto
https://github.com/fengyuanchen/cropperjs#moveto
https://github.com/fengyuanchen/cropperjs#rotateto
Accept all options in the docs as properties. Except previous mentioned options, other options don't take effect after component mount.
<Cropper
src='http://fengyuanchen.github.io/cropper/img/picture.jpg'
aspectRatio={16 / 9}
guides={false}
crop={this._crop} />
Assign a ref
attribute to use methods
class Demo extends Component {
_crop(){
const dataUrl = this.refs.cropper.getCroppedCanvas().toDataURL();
console.log(dataUrl);
},
render() {
return (
<Cropper
ref='cropper'
crop={this._crop.bind(this)} />
);
}
}
npm run build
npm run build-example
Fong Kuanghuei(fongkuanghui@gmail.com)
MIT
FAQs
Cropper as React components
The npm package @wadev12/react-cropper receives a total of 0 weekly downloads. As such, @wadev12/react-cropper popularity was classified as not popular.
We found that @wadev12/react-cropper 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.