-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
OverlayView re-rendered on map drag #198
Comments
@ninosaurus can you please create minimal reproduction at codesandbox? |
@ninosaurus By now I think your issue is related to |
Can you please also add |
@JustFly1984 I tried with memoizing renderBody but it's not fixed. |
@ninosaurus I have made some changes, please take a look |
Thanks @JustFly1984 but I still have same issue, here is an illustration: |
I have changed it a bit more and found your issue - you have a className "fade-scale-in" on div |
I know that, but that's the animation that we wanted, is there other way to do animation? |
I guess that's because map rerender the html element every time when map drags which then trigger css animation. I see that they provide API for animating Markers, but for OverlayView I had to do it with CSS. @JustFly1984 |
@ninosaurus sorry, can't help you with issue, lets wait for other maintainers, maybe they have any ideas. |
Well, it's really weird. Apparently Edit: Oh, wait ... why is this in here? That means it will re-render on each draw :) react-google-maps-api/packages/react-google-maps-api/src/components/dom/OverlayView.tsx Line 128 in 4f47f5f
|
As I see it was added by @uriklar |
@ninosaurus it is clearly a bug on our side, please wait till we fix it and publish new version |
The force update is there because the container element is repositioned on every map moved. I guess we could update it's style via ref instead of rerendering the component. I'll try to get to it later today |
@ninosaurus I believe the https://github.com/JustFly1984/react-google-maps-api/tree/issue-198-overlayview-force-update fixes the issue but I don't have time to test it right now. @ninosaurus you can clone the branch, run |
Well, Yarn workspaces have nothing with that really. And even if there wouldn't be monorepo, without actually commiting I do like using https://github.com/whitecolor/yalc when I need to use a fork/branch of some project without polluting NPM with it, but it still needs to clone the project and build it. I am not aware of any other prettier way. |
I think the fastest way to test, is to add the code from codesandbox to gatsby-example in the same branch, and test. PS: Honestly, It feels like lerna and yarn workspaces is making more trouble than solving issues. same is concerning tsdx. I do not have time today, but if there will be PR, I'll find time to merge and publish. |
Well, that's just a pitfall of modern tooling which ultimately makes sense. Without it you would need to write code in ES5, no ESM, no TypeScript. Also, there would be no UMD bundle and people would have run minification on their own. I would say it's not worth it just for a few cases when you need to test things out. If it's really something worrisome for you, then set up git hook (with Husky) to run build on every commit and add |
@ninosaurus Well, it looks like that culprit is somewhere else after all. The Considering it was working for you with tomchentw version, it surely must be something on our side, but I just tried to compare the code and besides using React.portal there is no other significant difference. |
I guess google maps overlay animation is not supposed to be done with css. @FredyC |
@ninosaurus @FredyC @uriklar at least we have found a performance bug and eliminated it. @FredyC can you please look at the call stack of draw function? |
@JustFly1984 It goes directly to minimized google maps, so that's pretty much impossible to get something useful from that, but it's clear it runs based on requestAnimationFrame so in general it should be suitable for animating stuff. @ninosaurus I don't know enough about CSS animations, but are you actually sure that it's enough like that? I mean it feels like such animation is about to be executed on every DOM redraw, there is no indication it should happen on "div appearence" only. I have a vague awareness of https://github.com/reactjs/react-transition-group which should be used for animating on mount/unmount. Isn't it actually something you need? |
I'll try that later today, it make sense to be working, thanks a lot guys. |
@ninosaurus can we close an issue? |
I consider this issue cosed, please request reopen if you have more questions |
I don't think that calling |
@FredyC thank you for clarification. I just wanted to save this url as reference to OverlayView, so we can fix performance issue at some point. |
will leave this issue open, until we apply the fix. |
Hi Guys, I have the same issue, but mine seems to be related to React 18 (and I assume it's due to the automatic batching). |
This issue was solved for me by using |
Hi, I refactored my app to use this library instead of react-google-maps, and I've found some problems with unnecessary rendering of OverlayView component.
I have events such as onMouseOver, onFocus, onMouseOut, onBlur, onClick on OverlayView children.
Environment
node --version: v10.15.1
Here is my package.json dependecies:
I'm using OverlayView for custom html styled markers as shown below:
How is it behave?
css: fade-scale-in is used for animating when element shows first time, by with every move/drag of map, I get rerendered that element and it trigger animation.
I turned on "why-did-you-update" and see that OverlayView portal is updated every time.
Is there any workaround or optimization needed in order to achieve this?
I tried with Marker component but I'm not able to do custom html inside it.
Thanks in advance.
The text was updated successfully, but these errors were encountered: