Skip to content

Commit ad2789f

Browse files
author
Bond
committed
Add more reliable check for component type
Nextjs changes the component name which makes determining a component type using the component name unreliable. This should work in all cases
1 parent 5eb162d commit ad2789f

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/components/StaticGoogleMap.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import MarkerGroupStrategy from '../strategies/markergroup';
99
import PathGroupStrategy from '../strategies/pathgroup';
1010
import DirectionStrategy from '../strategies/direction/index';
1111
import MapStrategy from '../strategies/map';
12+
import Marker from './Marker';
13+
import Path from './Path';
14+
import Direction from './Direction';
1215
import {
1316
isStatelessComponent,
1417
renderStatelessComponent,
@@ -63,16 +66,16 @@ class StaticGoogleMap extends Component {
6366
return null;
6467
}
6568

66-
switch (child.type.name) {
67-
case 'Marker':
69+
switch (child.type) {
70+
case Marker:
6871
return MarkerStrategy(child, props);
69-
case 'MarkerGroup':
72+
case Marker.Group:
7073
return MarkerGroupStrategy(child, props);
71-
case 'Path':
74+
case Path:
7275
return PathStrategy(child, props);
73-
case 'PathGroup':
76+
case Path.Group:
7477
return PathGroupStrategy(child, props);
75-
case 'Direction':
78+
case Direction:
7679
return DirectionStrategy(child, props);
7780
default:
7881
const componentType = child.type;

0 commit comments

Comments
 (0)