Skip to content

Commit df7df8f

Browse files
mfisher87nakul-py
andcommitted
Remove type assertion
Co-authored-by: Nakul Verma <[email protected]>
1 parent b478a85 commit df7df8f

File tree

1 file changed

+19
-15
lines changed
  • packages/base/src/dialogs/symbology/components/color_ramp

1 file changed

+19
-15
lines changed

packages/base/src/dialogs/symbology/components/color_ramp/ColorRamp.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ const ColorRamp: React.FC<IColorRampProps> = ({
5252
initialMin,
5353
initialMax,
5454
}) => {
55-
const [selectedRamp, setSelectedRamp] = useState('');
55+
const [selectedRamp, setSelectedRamp] = useState<ColorRampName | undefined>();
5656
const [selectedMode, setSelectedMode] = useState('');
5757
const [numberOfShades, setNumberOfShades] = useState('');
5858
const [minValue, setMinValue] = useState<number | undefined>(initialMin);
5959
const [maxValue, setMaxValue] = useState<number | undefined>(initialMax);
6060
const [isLoading, setIsLoading] = useState(false);
6161

6262
useEffect(() => {
63-
if (selectedRamp === '' && selectedMode === '' && numberOfShades === '') {
63+
if (selectedRamp === undefined && selectedMode === '' && numberOfShades === '') {
6464
populateOptions();
6565
}
6666
}, [layerParams]);
@@ -109,7 +109,12 @@ const ColorRamp: React.FC<IColorRampProps> = ({
109109
setMaxValue(initialMax);
110110
};
111111

112-
const rampDef = COLOR_RAMP_DEFINITIONS[selectedRamp as ColorRampName];
112+
if (selectedRamp === undefined) {
113+
// This should be set at this point!
114+
return;
115+
}
116+
const rampDef = COLOR_RAMP_DEFINITIONS[selectedRamp];
117+
113118
const normalizedCritical =
114119
rampDef?.type === 'Divergent' ? (rampDef.criticalValue ?? 0.5) : 0.5;
115120
const scaledCritical =
@@ -154,18 +159,17 @@ const ColorRamp: React.FC<IColorRampProps> = ({
154159
setSelectedMode={setSelectedMode}
155160
/>
156161
)}
157-
{rampDef && (
158-
<ColorRampValueControls
159-
min={displayMin}
160-
setMin={setMinValue}
161-
max={displayMax}
162-
setMax={setMaxValue}
163-
rampDef={rampDef}
164-
initialMin={initialMin}
165-
initialMax={initialMax}
166-
renderType={renderType}
167-
/>
168-
)}
162+
163+
<ColorRampValueControls
164+
min={displayMin}
165+
setMin={setMinValue}
166+
max={displayMax}
167+
setMax={setMaxValue}
168+
rampDef={rampDef}
169+
initialMin={initialMin}
170+
initialMax={initialMax}
171+
renderType={renderType}
172+
/>
169173

170174
{isLoading ? (
171175
<LoadingIcon />

0 commit comments

Comments
 (0)