Skip to content

useClusterer hook causes maximum depth error due to repeated setState calls #65

@usama-liaqat

Description

@usama-liaqat

Issue: useClusterer Hook Causes Maximum Depth Error Due to Repeated setState Calls

Description

After updating to the latest version, the useClusterer hook triggers unnecessary re-renders and eventually causes a maximum update depth exceeded error in React. It seems that the hook continuously calls setState, leading to an infinite render loop.

Expected Behavior

The hook should update its internal state only when cluster data actually changes, avoiding redundant updates and infinite loops.

Actual Behavior

The hook continuously calls setState, causing React to exceed the maximum render depth limit.

Comparison with Version 4.0

  • I tested the same logic with version 4.0, and it worked without issues.
  • After comparing both versions, I found that the new hook logic seems to trigger state updates unnecessarily.
  • I wrote my own hook by reusing the logic from version 4.0, and it works correctly with the latest version.

Suggested Fix

Refactor the useClusterer hook to prevent unnecessary state updates.
Reverting to or refactoring based on the 4.0 implementation logic should resolve this issue.

Environment

  • Library Version: Latest 5.0.2
  • React Native Version: 0.82.1
  • Platform(s): iOS / Android (both)

Additional Notes:
If needed, I can share my custom hook implementation that works without the repeated setState calls for reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions