pankod/refine

View on GitHub
packages/core/src/hooks/refine/useSyncWithLocation.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { useContext } from "react";

import { RefineContext } from "@contexts/refine";
import { IRefineContextOptions } from "../../contexts/refine/types";

type UseSyncWithLocationType = () => {
  syncWithLocation: IRefineContextOptions["syncWithLocation"];
};

/**
 * List query parameter values can be edited manually by typing directly in the URL.
 * To activate this feature `syncWithLocation` needs to be set to `true`.
 *
 * @see {@link https://refine.dev/docs/api-reference/core/components/refine-config/#syncwithlocation} for more details.
 */
export const useSyncWithLocation: UseSyncWithLocationType = () => {
  const { syncWithLocation } = useContext(RefineContext);

  return { syncWithLocation };
};