[Bug] InfoWindow flickering on re render (creating several portals?)

Open
#832 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start with the linked CodeSandbox reproduction and compare the first InfoWindow render with subsequent position changes. Trace the InfoWindow update and portal lifecycle, including the headerContent case, and verify that repeated updates do not add flicker or trigger the hover-driven loop.

Written by the indexing model from the issue text.

Description

bug
Description

When I open an InfoWindow for the first time, it works fine. But after I update the position (I tested with position, but could be true for other props), I can see the content flickering every time it re renders. It seems to get worse with every position change. If the position changed once, the content will blink once on re render. If position changed twice, content will blink twice and so on.

Maybe it's adding a new portal with every position change? I managed to fix the problem in some cases by using position as key of InfoWindow, which could indicate that something is not being cleaned up properly on props update. The "key" trick doesn't work when headerContent is set.

Steps to Reproduce

This is not the exact same scenario as I described, but it is an easier way to reproduce the same problem. In this case I am using the flickering to trigger an infinite loop: mouse enter -> update state -> flicker -> flicker causes mouse leave -> update state -> flicker -> mouse enter

CodeSandbox example: https://codesandbox.io/p/devbox/marker-issue-forked-kssrss?workspaceId=ws_AJApL5q2Q836HiYdKXszjW

  • Click anywhere on the map to open the InfoWindow
  • Notice that you can hover over the content elements to change the box color, at least the first time InfoWindow is opened
  • Click on another location on the map to move the InfoWindow
  • Hovering the elements should now trigger an infinite loop
Environment
  • Library version: 1.5.5
  • Google maps version: weekly
  • Browser and Version: Chrome Version 140.0.7339.133
  • OS: MacOS 15.6
Dominant language
TypeScript
Stars
2k
Forks
195
Avg merge
6h 26m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from visgl/react-google-maps

All issues in visgl/react-google-maps

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.