Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[fix] Custom picker fix when called during initialization (#3107)

Igor Dykhta0dcacc66eb24
diff --git a/src/components/src/side-panel/layer-panel/custom-picker.tsx b/src/components/src/side-panel/layer-panel/custom-picker.tsx
index 2ef6975e9..33173e15f 100644
--- a/src/components/src/side-panel/layer-panel/custom-picker.tsx
+++ b/src/components/src/side-panel/layer-panel/custom-picker.tsx
@@ -6,6 +6,7 @@ import styled, {withTheme} from 'styled-components';
import {SketchPicker, ColorChangeHandler} from 'react-color';
import {HexColor} from '@kepler.gl/types';
+import {panelBackground} from '@kepler.gl/styles';
import {BaseComponentProps} from '../../types';
@@ -65,7 +66,20 @@ type CustomPickerProps = {
onChange: ColorChangeHandler;
};
-const CustomPicker: React.FC<CustomPickerProps> = ({color, onChange, theme}: CustomPickerProps) => {
+const defaultProps: CustomPickerProps = {
+ color: '#f00',
+ theme: {
+ panelBackground
+ },
+ onChange: () => {
+ // no-op
+ }
+};
+
+// Note: When using SketchPicker, the parent component CustomPicker can be invoked as a function without props by ReactDOM.
+const CustomPicker: React.FC<CustomPickerProps> = (props = defaultProps) => {
+ const {color, onChange, theme} = props;
+
const pickerStyle = useMemo(
() => ({
picker: {