Skip to content

feat(react): tanstack v4 for member management#299

Open
chakrihacker wants to merge 5 commits into
feat/member-managementfrom
feat/tanstack-v4-for-member-management
Open

feat(react): tanstack v4 for member management#299
chakrihacker wants to merge 5 commits into
feat/member-managementfrom
feat/tanstack-v4-for-member-management

Conversation

@chakrihacker
Copy link
Copy Markdown
Contributor

@chakrihacker chakrihacker commented May 25, 2026

Summary

Adds support for Tanstack v4

Why

What

Packages

  • packages/core
  • packages/react
  • examples

References

Testing

How can this be verified? Note anything intentionally not covered by tests and why.

  • This change adds unit test coverage
  • Tested for both SPA and RWA flows, all example apps working
  • All existing and new tests complete without errors

Checklist

  • Breaking change
  • Requires docs update
  • Backward compatible

Contributing

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 25, 2026

Codecov Report

❌ Patch coverage is 75.91538% with 592 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.32%. Comparing base (9aec426) to head (81ea5a9).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
...my-organization/organization-member-management.tsx 0.52% 188 Missing ⚠️
...organization/use-organization-member-management.ts 0.59% 167 Missing ⚠️
...invitation-table/organization-invitation-table.tsx 0.68% 146 Missing ⚠️
...on-create/organization-invitation-create-modal.tsx 71.62% 61 Missing ⚠️
...s/react/src/components/auth0/shared/data-table.tsx 89.77% 9 Missing ⚠️
...r-roles/organization-member-assign-roles-modal.tsx 93.75% 5 Missing ⚠️
...n/shared/services/use-member-management-service.ts 97.29% 5 Missing ⚠️
...ation/shared/services/use-member-detail-service.ts 97.05% 4 Missing ⚠️
...act/src/hooks/my-organization/use-member-detail.ts 97.36% 3 Missing ⚠️
...-management/shared/search-filter/search-filter.tsx 96.15% 2 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #299      +/-   ##
==========================================
- Coverage   89.59%   87.32%   -2.27%     
==========================================
  Files         155      180      +25     
  Lines       13084    15523    +2439     
  Branches     1803     2116     +313     
==========================================
+ Hits        11722    13555    +1833     
- Misses       1362     1968     +606     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chakrihacker chakrihacker changed the base branch from main to feat/member-management May 25, 2026 20:00
@chakrihacker chakrihacker marked this pull request as ready for review May 25, 2026 20:01
Comment on lines +127 to +133
isRemovingFromOrg: removeFromOrgMutation.isPending ?? (removeFromOrgMutation as any).isLoading,
isAssigningRoles: assignRolesMutation.isPending ?? (assignRolesMutation as any).isLoading,
isRemovingRoles: removeRolesMutation.isPending ?? (removeRolesMutation as any).isLoading,
removingRoleIds:
(removeRolesMutation.isPending ?? (removeRolesMutation as any).isLoading)
? removingRoles.map((r) => r.id)
: [],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned in #300 (comment)

Comment on lines +28 to +32
const keepPreviousDataOption =
typeof keepPreviousData === 'function'
? { placeholderData: keepPreviousData }
: ({ keepPreviousData: true } as object);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to make it more type safe

`import { keepPreviousData } from '@tanstack/react-query';

type KeepPreviousDataOptionV5 = { placeholderData: typeof keepPreviousData };
type KeepPreviousDataOptionV4 = { keepPreviousData: true };
type KeepPreviousDataOption = KeepPreviousDataOptionV5 | KeepPreviousDataOptionV4;

export function getKeepPreviousDataOption(): KeepPreviousDataOption {
// v5 exports keepPreviousData as a function
if (typeof keepPreviousData === 'function') {
return { placeholderData: keepPreviousData };
}
// v4 uses boolean option
return { keepPreviousData: true };
}`

- add isMutationPending and getKeepPreviousDataOption helpers
- update member management hooks to use compat utilities
- remove as any casts and direct keepPreviousData usage
* In v5, `keepPreviousData` boolean option was replaced by `placeholderData: keepPreviousData`.
* @returns The appropriate option object to spread into a query config.
*/
export function getKeepPreviousDataOption(): KeepPreviousDataOption {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename this to **getPreviousDataOption**


type KeepPreviousDataOptionV5 = { placeholderData: typeof keepPreviousData };
type KeepPreviousDataOptionV4 = { keepPreviousData: true };
type KeepPreviousDataOption = KeepPreviousDataOptionV5 | KeepPreviousDataOptionV4;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename this to PreviousDataOption

}

type KeepPreviousDataOptionV5 = { placeholderData: typeof keepPreviousData };
type KeepPreviousDataOptionV4 = { keepPreviousData: true };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename ** LegacyKeepPreviousOption**

return mutation.isPending ?? mutation.isLoading ?? false;
}

type KeepPreviousDataOptionV5 = { placeholderData: typeof keepPreviousData };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename ** PlaceholderDataOption**

import type { UseMutationResult } from '@tanstack/react-query';
import { keepPreviousData } from '@tanstack/react-query';

type MutationV4Compat = { isLoading?: boolean };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look and seems its not needed

Comment on lines +18 to +22
export function isMutationPending<
T extends Pick<UseMutationResult, 'isPending'> & MutationV4Compat,
>(mutation: T): boolean {
return mutation.isPending ?? mutation.isLoading ?? false;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update this as

`
export function isMutationLoading<
T extends Pick<UseMutationResult, 'isPending'> & { isLoading?: boolean },

(mutation: T): boolean {
return mutation.isPending ?? mutation.isLoading ?? false;
}

`

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.

3 participants