Access MapRef outside Map Component #261
Unanswered
petritnuredini
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, I am building an app with NextJS. My main Goal is when user clicks on the list item in the right side a function pan the map to the marker of that company.
I have this screen:
They are in different Components (Files), but I am using a react hook that has this function
in 1st case this is called from Marker component
same way I am using this component from ExplorerListItems, but, when I click the marker I get this:
When I click the Explorer List Item I get this:
Can't access the mapRef data.
I tried to save the mapRef with Redux state, didn't work.
Tried to access the mapRef from the hook, didn't work.
Haven't tried to use React Context yet.
Any idea how to access the mapRef and Pan Feature from different component?
Thank you in advance. 🙏🏻
****** Edited on 14 May 2024 ******
I managed to handle this by adding useContext on the project and saving the ref as global state.
Leaving it here just in case anyone needs it in the future. ✌🏻
Beta Was this translation helpful? Give feedback.
All reactions