react-color
Version:
A Collection of Color Pickers from Sketch, Photoshop, Chrome & more
38 lines (32 loc) • 813 B
Markdown
id: api-onChange
title: onChange
Pass a function to call every time the color is changed. Use this to store the color in the state of a parent component or to make other transformations.
Keep in mind this is called on drag events that can happen quite frequently. If you just need to get the color once use `onChangeComplete`.
```
var React = require('react');
var ColorPicker = require('react-color');
class Component extends React.Component {
handleChange(color) {
// color = {
// hex: '#333',
// rgb: {
// r: 51,
// g: 51,
// b: 51,
// a: 1,
// },
// hsl: {
// h: 0,
// s: 0,
// l: .20,
// a: 1,
// },
// }
}
render() {
return <ColorPicker onChange={ this.handleChange } />;
}
}
```