Skip to content

Commit

Permalink
fix: remove explicit types for components using forwardRef (#620)
Browse files Browse the repository at this point in the history
closes #619
closes #617
  • Loading branch information
usefulthink authored Nov 28, 2024
1 parent c9f2b0f commit 8448a33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/components/advanced-marker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, {
Children,
CSSProperties,
forwardRef,
ForwardRefExoticComponent,
useCallback,
useEffect,
useImperativeHandle,
Expand Down Expand Up @@ -275,8 +274,8 @@ function useAdvancedMarker(props: AdvancedMarkerProps) {
return [marker, contentContainer] as const;
}

export const AdvancedMarker: ForwardRefExoticComponent<AdvancedMarkerProps> =
forwardRef((props, ref: Ref<AdvancedMarkerRef>) => {
export const AdvancedMarker = forwardRef(
(props: AdvancedMarkerProps, ref: Ref<AdvancedMarkerRef>) => {
const {children, style, className, anchorPoint} = props;
const [marker, contentContainer] = useAdvancedMarker(props);

Expand All @@ -300,7 +299,8 @@ export const AdvancedMarker: ForwardRefExoticComponent<AdvancedMarkerProps> =
)}
</AdvancedMarkerContext.Provider>
);
});
}
);

export function useAdvancedMarkerRef() {
const [marker, setMarker] =
Expand Down
13 changes: 5 additions & 8 deletions src/components/marker.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable complexity */
import React, {
forwardRef,
ForwardRefExoticComponent,
useCallback,
useEffect,
useImperativeHandle,
Expand Down Expand Up @@ -119,15 +118,13 @@ function useMarker(props: MarkerProps) {
/**
* Component to render a marker on a map
*/
export const Marker: ForwardRefExoticComponent<MarkerProps> = forwardRef(
(props: MarkerProps, ref: MarkerRef) => {
const marker = useMarker(props);
export const Marker = forwardRef((props: MarkerProps, ref: MarkerRef) => {
const marker = useMarker(props);

useImperativeHandle(ref, () => marker, [marker]);
useImperativeHandle(ref, () => marker, [marker]);

return <></>;
}
);
return <></>;
});

export function useMarkerRef() {
const [marker, setMarker] = useState<google.maps.Marker | null>(null);
Expand Down

0 comments on commit 8448a33

Please sign in to comment.