mirror of https://gitee.com/antv-l7/antv-l7
Merge pull request #224 from antvis/fix/react-scene
fix: 修复MapboxScene的容器找不到
This commit is contained in:
commit
547ebf4403
|
@ -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;
|
||||
|
|
|
@ -25,7 +25,7 @@ export default React.memo((props: IMapSceneConig) => {
|
|||
};
|
||||
}, []);
|
||||
|
||||
return scene !== null && scene !== undefined ? (
|
||||
return (
|
||||
<SceneContext.Provider value={scene}>
|
||||
{createElement(
|
||||
'div',
|
||||
|
@ -37,5 +37,5 @@ export default React.memo((props: IMapSceneConig) => {
|
|||
scene && props.children,
|
||||
)}
|
||||
</SceneContext.Provider>
|
||||
) : null;
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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