jbetancur / react-data-table-component

A responsive table library with built-in sorting, pagination, selection, expandable rows, and customizable styling.
https://react-data-table-component.netlify.app
Apache License 2.0
2.05k stars 413 forks source link

defaultSortAsc and defaultSortFieldId is not changed sometimes #1113

Closed andy-yu-y closed 1 year ago

andy-yu-y commented 2 years ago

defaultSortAsc and defaultSortFieldId work differently as paginationDefaultPage. when path is changed, i use use-effect to refetch the table data, but defaultSortAsc and defaultSortFieldId wont changed under this condition, in the meanwhile paginationDefaultPage works fine.

I think there is bug about this, defaultSortAsc and defaultSortFieldId only works when user refresh the page. For paginationDefaultPage, it take effect when table data fetched everytime. Below is the code for your reference: <DataTable title={title} theme={window.THEME.palette.type} ........... paginationDefaultPage={pageRef.current} paginationPerPage={pageSizeRef.current} paginationRowsPerPageOptions={rowsPerPage} paginationComponentOptions={{ rowsPerPageText: 'Shows per page:', rangeSeparatorText: 'out of', }} ......... sortServer onSort={handleSort} defaultSortAsc={sortIndicatorRef.current} defaultSortField={sortByRef.current} sortIcon={} />

andy-yu-y commented 2 years ago

Found one history issue related to this: https://github.com/jbetancur/react-data-table-component/pull/590

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

andy-yu-y commented 1 year ago

issue still there