deckgl-typings
deckgl-typings copied to clipboard
[HELP] - How to pass generic type to OnClick DeckGL
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)
}}
/>
Hi @danmarshall , any help on this would be appreciated
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)
})}
/>
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<D> that i was just missing a trick