mirror of https://gitee.com/antv-l7/antv-l7
fix: 修复MapboxScene的容器找不到
This commit is contained in:
parent
ee30732a8a
commit
64a2f53cd4
|
@ -33,7 +33,7 @@ const AMapScene = React.memo((props: IMapSceneConig) => {
|
|||
scene.setMapStyle(map.style);
|
||||
}, [map.style]);
|
||||
|
||||
return scene !== undefined ? (
|
||||
return (
|
||||
<SceneContext.Provider value={scene}>
|
||||
{createElement(
|
||||
'div',
|
||||
|
@ -45,7 +45,7 @@ const AMapScene = React.memo((props: IMapSceneConig) => {
|
|||
scene && props.children,
|
||||
)}
|
||||
</SceneContext.Provider>
|
||||
) : null;
|
||||
);
|
||||
});
|
||||
|
||||
export default AMapScene;
|
||||
|
|
|
@ -58,7 +58,7 @@ const MapboxScene = React.memo((props: IMapSceneConig) => {
|
|||
}
|
||||
}, [map.rotation]);
|
||||
|
||||
return scene !== undefined ? (
|
||||
return (
|
||||
<SceneContext.Provider value={scene}>
|
||||
{createElement(
|
||||
'div',
|
||||
|
@ -70,7 +70,7 @@ const MapboxScene = React.memo((props: IMapSceneConig) => {
|
|||
scene && props.children,
|
||||
)}
|
||||
</SceneContext.Provider>
|
||||
) : null;
|
||||
);
|
||||
});
|
||||
|
||||
export default MapboxScene;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { Scene } from '@antv/l7';
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
export const SceneContext = createContext({});
|
||||
// tslint:disable-next-line: no-object-literal-type-assertion
|
||||
export const SceneContext = createContext<Scene | undefined>({} as Scene);
|
||||
export function useSceneValue(): Scene {
|
||||
return (useContext(SceneContext) as unknown) as Scene;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue