-
Notifications
You must be signed in to change notification settings - Fork 837
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
updating center from parent does not reposition map #546
Comments
@jseparovic Do you interact with the map before you change the center? If that is the case, this might be related to #176 and your solution would be using If you're not interacting with the map, and you trying to change the center, I need to know what is the method you're using to change the center. Please provide a live example if possible. |
@itsmichaeldiego I'm just using the parent state and updating it when a user finds a google place in a search field (using react-places-autocomplete) The handler method looks like:
updateState function is just a setState wrapper:
And the component in the parent render()
|
@itsmichaeldiego I've tried to setup a demo For some reason the map doesn't show in the demo I'm trying to simulate the update in parent state to show the map not recentering, but not having much luck |
@jseparovic Have you tried this? #512 (comment) |
@itsmichaeldiego I did try that, but I thought that was more for resizing the browser window? |
@itsmichaeldiego is it possibly a v16 issue? That's what I'm using in my project, and same in the codesandbox |
@itsmichaeldiego I have the codesandbox showing the issue now. center is updated, but the map does not recenter: https://codesandbox.io/s/mjp08rvxmj This is also using v16.2.0 |
@jseparovic You're right, I can reproduce it, let me work on an example on my own to see how can we make this work! |
@jseparovic Hey, I think the problem is related on how the state works. Check this repo I created a while ago for an interview, here I change the center: https://github.com/itsmichaeldiego/earthquaker. |
@itsmichaeldiego you're right, it was my updateState setState wrapper. For some reason I thought I had to update this way to maintain other state keys, but I see setState already does this. working here: https://codesandbox.io/s/2oy1nj9kyy |
Great @jseparovic, I am glad I was helpful! |
@itsmichaeldiego interestingly I encountered this problem again using v1.1.7. After a couple of hours of trying every solution listed in the repo issues, downgrading from v1.1.7 to v0.34.0 fixed the issue. Upgrading to v2.0.4 also brings the issue back again! This can be seen by trying the different package versions on @jseparovic's sandbox: #546 (comment) |
I've encountered a similar issue. Assume the following code:
Execute the following steps:
This might seem weird, but in fact that's not surprising. On the following scenario Such a behavior of component might be confusing. IMHO, when deciding whether to re-center map programmatically, it makes sense to compare |
sorry, I've searched and can't seem to find the answer.
I'm updating center of map from parent component but the map is not repositioning. What am I missing here?
Cheers
The text was updated successfully, but these errors were encountered: