Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] - How to pass generic type to OnClick DeckGL #252

Open
SadikMoazzem opened this issue Jun 6, 2022 · 3 comments
Open

[HELP] - How to pass generic type to OnClick DeckGL #252

SadikMoazzem opened this issue Jun 6, 2022 · 3 comments

Comments

@SadikMoazzem
Copy link

onClick: <D>(info: PickInfo<D>, e: MouseEvent) => any;
2244:deck.gl__core

RE this guy in the DeckGL Core types, i cant figure out how to pass the "D" Generic type to the prop

Here is a snippet of the code

<DeckGL<any>
  ref={deckRef}
  viewState={mapViewport}
  controller
  layers={deckLayers}
  ContextProvider={MapContext.Provider}
  onWebGLInitialized={setGLContext}
  onClick={<DeviceData>(clickInfo) => {
      console.log(clickInfo)
  }}
/>
@SadikMoazzem
Copy link
Author

Hi @danmarshall , any help on this would be appreciated

@danmarshall
Copy link
Owner

H1 @SadikMoazzem , this is quite puzzling. Hopefully another community member can chime in, or you can try Stack Overflow.

Here's the best I can do:

interface DeviceData {
    abc: number;
}
    <DeckGL<any>
        onClick={((clickInfo) => {
            const deviceData = clickInfo.object as unknown as DeviceData;
            console.log(deviceData.abc)
        })}
    />

@SadikMoazzem
Copy link
Author

I'll try that out. Thanks for the quick reply!!

I was assuming as the type for the onClick allowed to pass in a Type that i was just missing a trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants