Skip to content

Conversation

@neotob
Copy link
Collaborator

@neotob neotob commented Dec 22, 2025

No description provided.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/neolution-ch/react-data-table/@neolution-ch/react-data-table@87

commit: 8dca9df


useEffect(() => {
// We can't set these values directly in the useReactDataTableState hook above,
// because the filter would be taken as default value also for the reset function.
Copy link
Contributor

Choose a reason for hiding this comment

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

@neotob so the idea here is to "rehydrate" the state on mount right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Michele-Masciave yes exactly, so a page reload will keep the previous data

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect I see, LGTM then :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I know the useEffect is not that beautiful... if you see any other solution, please let me know 🙏

setSorting,
} = useReactDataTableState<TData, TFilter>({
initialColumnPinning:
getLocalStorageItem<useReactDataTableStateProps<TData, TFilter>["initialColumnPinning"]>(`${props.localStorageKey}_columnPinning`) ??
Copy link
Collaborator

Choose a reason for hiding this comment

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

@neotob Can I ask why you try to read the localstorage here?
The useEffect is not enough?

Copy link
Collaborator

Choose a reason for hiding this comment

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

How many times the query will be executed on the first render? 1 or 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@manni497 I need to have the useEffect because the initial values didn;t decide between filter and afterSearchFilter... I added it now instead and was able to get ride of the useEffect.. I think this is better right?
It also loads directly correct ond the first query and will only do one call

@neotob neotob requested a review from manni497 January 16, 2026 08:49

### Added

- added the `usePersistentReactDataTableState` hook which saves it's own state into the local storage
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

add the new prop

/**
* the initial after search filter
*/
initialAfterSearchFilter?: ColumnFilterState<TFilter>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@neotob Just curios of this use case, there could be really a case in which the initial column filters is different than the after search filter?

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