Skip to content

Commit

Permalink
feat(layer): 优化类型
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxingkang committed Sep 1, 2022
1 parent 1cec2ef commit 10e2b32
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/layer/layer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { useEffect, useState } from 'react';

import { useMap } from '@/hooks/useMap';

import type { FC } from 'react';
import type { AnyLayer } from 'mapbox-gl';
import type { LayerProps } from './types';
import type { LayerProps, LayerType } from './types';

export const Layer: FC<LayerProps> = (props) => {
export const Layer = <T extends LayerType>(props: LayerProps<T>) => {
const { before, ...rest } = props;
const map = useMap();
const [layer, setLayer] = useState<AnyLayer>();
Expand All @@ -15,7 +14,7 @@ export const Layer: FC<LayerProps> = (props) => {
if (map) {
map.addLayer(rest as AnyLayer, before);

setLayer(map.getLayer(props.id));
// setLayer(map.getLayer(props.id));
}
}, [map]);

Expand Down

0 comments on commit 10e2b32

Please sign in to comment.