I'm using React Color for my project. So I added ChromePicker
as in the example into the code.
When the button is clicked, the picker is shown, when it's clicked outside of it - it gets closed. So far so good, it works as expected.
But if I try to change the color, to move the circle or the bars below the gradient there is no action, they are not moving. I don't know why is this happening.
Here is my code:
import React from 'react';
import { Button } from 'semantic-ui-react';
import { ChromePicker } from 'react-color';
export default class Banner extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
displayColorPicker: false,
};
}
handleClick = () => {
this.setState({ displayColorPicker: true });
};
handleClose = () => {
this.setState({ displayColorPicker: false });
};
render() {
const popover = {
position: 'absolute',
zIndex: '2',
};
const cover = {
position: 'fixed',
top: '0px',
right: '0px',
bottom: '0px',
left: '0px',
};
return (
<div>
...//some other code
<div>
<Button onClick={this.handleClick}>Pick Color</Button>
{this.state.displayColorPicker ? (
<div style={popover}>
<div
style={cover}
onClick={this.handleClose}
onKeyDown={this.handleClick}
role="button"
tabIndex="0"
aria-label="Save"
/>
<ChromePicker />
</div>
) : null}
</div>
</div>
);
}
}
import React from 'react';
import { SketchPicker } from 'react-color';
class Component extends React.Component {
state = {
background: '#fff',
};
handleChangeComplete = (color) => {
this.setState({ background: color.hex });
};
render() {
return (
<SketchPicker
color={ this.state.background }
onChangeComplete={ this.handleChangeComplete }
/>
);
}
}
You should use the onChangeComplete props I suppose, you can find further info here