mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-16 15:44:49 +00:00
unsubscrive from onchange listener on unmount
This commit is contained in:
parent
69e043fd57
commit
ae4bfda554
1 changed files with 3 additions and 1 deletions
|
|
@ -21,12 +21,14 @@ const ColorPicker = ({ className, value, onChange }) => {
|
|||
});
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
pickerRef.current.off('change');
|
||||
pickerRef.current.on('change', (picker, color) => {
|
||||
if (typeof onChange === 'function') {
|
||||
onChange(AColorPicker.parseColor(color, COLOR_FORMAT));
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
pickerRef.current.off('change');
|
||||
};
|
||||
}, [onChange]);
|
||||
React.useEffect(() => {
|
||||
if (AColorPicker.parseColor(pickerRef.current.color, COLOR_FORMAT) !== value) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue