You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `useListQuery` hook is used to subscribe to the data, current query, and other properties used within the List View. You can use this hook within any Custom Component rendered within the List View.
729
+
730
+
```tsx
731
+
'use client'
732
+
import { useListQuery } from'@payloadcms/ui'
733
+
734
+
const MyComponent:React.FC= () => {
735
+
// highlight-start
736
+
const { data, query } =useListQuery()
737
+
// highlight-end
738
+
739
+
// ...
740
+
}
741
+
```
742
+
743
+
The `useListQuery` hook returns an object with the following properties:
|**`data`**| The data that is being displayed in the List View. |
748
+
|**`defaultLimit`**| The default limit of items to display in the List View. |
749
+
|**`defaultSort`**| The default sort order of items in the List View. |
750
+
|**`handlePageChange`**| A method to handle page changes in the List View. |
751
+
|**`handlePerPageChange`**| A method to handle per page changes in the List View. |
752
+
|**`handleSearchChange`**| A method to handle search changes in the List View. |
753
+
|**`handleSortChange`**| A method to handle sort changes in the List View. |
754
+
|**`handleWhereChange`**| A method to handle where changes in the List View. |
755
+
|**`query`**| The current query that is being used to fetch the data in the List View. |
756
+
721
757
## useLocale
722
758
723
759
In any Custom Component you can get the selected locale object with the `useLocale` hook. `useLocale` gives you the full locale object, consisting of a `label`, `rtl`(right-to-left) property, and then `code`. Here is a simple example:
0 commit comments