pankod/refine

View on GitHub
packages/core/src/hooks/router/use-link/index.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import { RouterContext } from "@contexts/router";
import React, { useContext } from "react";

export const useLink = () => {
  const routerContext = useContext(RouterContext);

  if (routerContext?.Link) {
    return routerContext.Link;
  }

  const FallbackLink: Required<typeof routerContext>["Link"] = ({
    to,
    ...rest
  }) => <a href={to} {...rest} />;

  return FallbackLink;
};