Skip to content

Comments

fix: Multiple Search API Triggered (closes #1413)#1416

Open
rpsinghcodes wants to merge 1 commit intoidurar:masterfrom
rpsinghcodes:issues/fix-multiple-search-api-calls
Open

fix: Multiple Search API Triggered (closes #1413)#1416
rpsinghcodes wants to merge 1 commit intoidurar:masterfrom
rpsinghcodes:issues/fix-multiple-search-api-calls

Conversation

@rpsinghcodes
Copy link

Description

This pull request fixes an issue where the search API was being triggered multiple times on initial page load, even when no data was available.

The root cause was the use of dynamically generated keys (shortid()) for components rendered inside PageHeader. Since a new key was generated on every render, React treated these components as new instances, causing them to unmount and remount repeatedly, which re-triggered side effects and search API calls.

The fix removes the use of dynamically generated keys and relies on stable component rendering to prevent unnecessary re-renders and API calls.

Related Issues

  • Fixes: Search API triggered multiple times when no data is available

Steps to Test

  1. Navigate to any module using the shared DataTable component (e.g. Quotes, Invoices, Payments).
  2. Open the Network tab in the browser developer tools.
  3. Reload the page.
  4. Verify that the search API is called only once on initial load.
  5. Confirm that no additional search calls are triggered unless:
    • Typing in the search input
    • Clicking refresh
    • Changing filters or pagination

Screenshots (if applicable)

N/A – no visual UI changes.

Checklist

  • I have tested these changes
  • I have updated the relevant documentation (not required for this fix)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the codebase
  • My changes generate no new warnings or errors
  • The title of my pull request is clear and descriptive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant