【问题标题】:How to integrate DeckGL with react typescript?如何将 DeckGL 与 react typescript 集成?
【发布时间】:2022-08-16 23:15:00
【问题描述】:

尝试使用deckgl 与打字稿反应。但是效果不佳,我面临问题。有人知道怎么修这个东西吗 ?

\'DeckGL\' cannot be used as a JSX component. Its instance type \'DeckGL<ContextProviderValue>\' is not a valid JSX element. The types returned by \'render()\' are incompatible between these types. Type \'ReactElement<any, string | JSXElementConstructor<any>>\' is not assignable to type \'ReactNode\'. Property \'children\' is missing in type \'ReactElement<any, string | JSXElementConstructor<any>>\' but required in type \'ReactPortal\'.

import DeckGL from \'@deck.gl/react\';



  return (
    <Container>
      <DeckGL
        initialViewState={INITIAL_VIEW_STATE}
        controller={{ doubleClickZoom: false }}
        onClick={onLayerClick}
        layers={[layers]}
        getCursor={layers.getCursor.bind(layers)}
      >
        <Map
          style={{ width: \'100%\', height: \'100%\' }}
          mapStyle=\"mapbox://styles/mapbox/streets-v11\"
          mapboxAccessToken={process.env.REACT_APP_MAPBOX_ACCESS_TOKEN || \'\'}
        >
          <NavigateButton />
        </Map>
      </DeckGL>
    </Container>
  );
};

export default MapEdit;
  • 你修好了吗?我遇到了同样的问题?
  • 你使用打字稿吗?我只是添加: // eslint-disable-next-line import/no-named-as-default import DeckGL from \'@deck.gl/react\';

标签: reactjs typescript deck.gl


【解决方案1】:
import DeckGL from '@deck.gl/react/typed';

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-30
    • 2019-07-12
    • 2019-06-08
    • 2020-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-29
    相关资源
    最近更新 更多