Skip to content

Commit

Permalink
Add display name to map controls and compare
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfdsilva committed Oct 24, 2023
1 parent bd3440c commit a0a5cad
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ export default function CustomAoIControl(props: CustomAoIProps) {
});
return null;
}

CustomAoIControl.displayName = 'CustomAoIControl';
2 changes: 2 additions & 0 deletions app/scripts/components/common/map/controls/aoi/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ export default function DrawControl(props: DrawControlProps) {

return aoisFeatures.length ? null : <Css />;
}

DrawControl.displayName = 'DrawControl';
2 changes: 2 additions & 0 deletions app/scripts/components/common/map/controls/coords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ export default function MapCoordsControl() {

return null;
}

MapCoordsControl.displayName = 'MapCoordsControl';
2 changes: 2 additions & 0 deletions app/scripts/components/common/map/controls/geocoder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ export default function GeocoderControl() {

return null;
}

GeocoderControl.displayName = 'GeocoderControl';
4 changes: 4 additions & 0 deletions app/scripts/components/common/map/controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export function NavigationControl() {
return <MapboxGLNavigationControl position='top-left' showCompass={false} />;
}

NavigationControl.displayName = 'NavigationControl';

export function ScaleControl() {
return <MapboxGLScaleControl position='bottom-left' />;
}

ScaleControl.displayName = 'ScaleControl';
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,5 @@ export default function MapOptionsControl(props: MapOptionsProps) {
});
return null;
}

MapOptionsControl.displayName = 'MapOptionsControl';
2 changes: 2 additions & 0 deletions app/scripts/components/common/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export function Compare({ children }: { children: ReactNode }) {
return <>{children}</>;
}

Compare.displayName = 'Compare';

export default function MapProviderWrapper(props: MapsContextWrapperProps) {
return (
<MapProvider>
Expand Down
7 changes: 5 additions & 2 deletions app/scripts/components/common/map/maps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, {
Children,
useMemo,
ReactElement,
JSXElementConstructor,
useState,
createContext
} from 'react';
Expand Down Expand Up @@ -92,7 +91,11 @@ function Maps({ children, projection }: MapsProps) {

const sortedChildren = childrenArr.reduce(
(acc, child) => {
const componentName = (child.type as JSXElementConstructor<any>).name;
// This is added so that we can use the component name in production
// where the function names are minified
// @ts-expect-error displayName is not in the type
const componentName = child.type.displayName ?? '';

if (componentName === 'Compare') {
acc.compareGenerators = Children.toArray(
child.props.children
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,5 @@ export function AnalysisMessageControl() {

return null;
}

AnalysisMessageControl.displayName = 'AnalysisMessageControl';

0 comments on commit a0a5cad

Please sign in to comment.