Closed moranbw closed 2 years ago
Thanks for opening the issue, and providing code. If you could create a codesandbox demonstrating the issue, it would be immensely helpful. I am extremely busy and have very little time to recreate issues, but if you can present me with the issue in a sandbox, I can take a look, thanks.
@slutske22 thanks for the prompt reply. Here's a minimal example: https://stackblitz.com/edit/vitejs-vite-vrfcaw?file=src/App.tsx
You should be able to see the TypeScript issue on line 18. In my own code, I'm just currently doing a //@ts-ignore
to supress the issue.
Thanks in advance.
(note this code editor only seems to work well in Chrome, not Firefox)
I see the issue. I think I know what the problem is - I've wrapped the return value of the ref in forwardRef in React.RefObject
, which I guess is wrong. I'll try to come back and fix this when I have time. For now you can fake it out by doing this
const tileLayerRef = React.useRef<React.RefObject<EsriTiledMapLayer>>(null);
// then to still get intellisense when using it:
(tileLayerRef.current as EsriTiledMapLayer).bringToBack() // or some other leaflet layer method here
Not sure when I can push a new version with the fix, I'll leave this open for now.
@slutske22 thanks for the workaround. No rush as it's not blocking me. If I have any time I may look into it as well, if you're open to contributions.
This is fixed in version 2, which is currently in a @next version. You can try it out here: https://www.npmjs.com/package/react-esri-leaflet/v/2.0.0, npm i react-esri-leaflet@next
, Will publish as official version soon.
Perhaps related to this issue, I'm having some issues with refs andTiledMapLayer. Minimal example of my code is below:
Perhaps my tsconfig is too strict...but I'm receiving the following error:
Is there something going on with the way forwardRef is being used? Let me know if there's any more information I can provide.
Thanks -- and great work on this project!