useParsed
useParsed is a hook that leverages the parse method of the routerProvider to access the URL and query parameters along with the inferred resource, action and id from the URL.
Usageโ
import { useParsed } from "@refinedev/core";
type MyParams = {
someParam: string;
};
const MyComponent = () => {
const {
resource,
action,
id,
pathname,
params: {
filters,
sorters,
current,
pageSize,
...restParams // TParams - Any other parameters are also parsed and available in `params`
},
} = useParsed<MyParams>();
/* ... */
};
Return Valuesโ
resourceโ
This is the active resource that is matched by the current route and the action definitions in the resources array of the Refine component. It will be undefined if there is no match.
actionโ
This is the active action that is matched by the current route and the action definitions in the resources array of the Refine component. It will be undefined if there is no match.
idโ
This is the main parameter used by the Refine in API interactions. It will also be available in the params object but it is also available as a separate value for convenience. It will be undefined if there is no id parameter in the URL.
pathnameโ
This is the current pathname of the URL.
params.filtersโ
This is the filters that are parsed from the URL. It will be undefined if there is no filters parameter in the URL. This property is used in the syncWithLocation feature of the useTable.
params.sortersโ
This is the sorters that are parsed from the URL. It will be undefined if there is no sorters parameter in the URL. This property is used in the syncWithLocation feature of the useTable.
params.currentโ
This is the current page that is parsed from the URL. It will be undefined if there is no current parameter in the URL. This property is used in the syncWithLocation feature of the useTable.
params.pageSizeโ
This is the page size that is parsed from the URL. It will be undefined if there is no pageSize parameter in the URL. This property is used in the syncWithLocation feature of the useTable.
paramsโ
This is the object that contains all the parameters that are parsed from the URL. It will be an empty object if there is no parameter in the URL. params object contains both the URL parameters and the query parameters.