UNPKG

@generouted/react-router

Version:

Generated file-based routes for React Router and Vite

35 lines (33 loc) 970 B
// src/client/components.tsx import { forwardRef } from "react"; import { generatePath, Link, Navigate } from "react-router"; import { jsx } from "react/jsx-runtime"; var components = () => { return { // @ts-expect-error Link: forwardRef(({ to, params, ...props }, ref) => { const path = generatePath(typeof to === "string" ? to : to.pathname, params || {}); return /* @__PURE__ */ jsx( Link, { ref, ...props, to: typeof to === "string" ? path : { pathname: path, search: to.search, hash: to.hash } } ); }), Navigate: ({ to, params, ...props }) => { const path = generatePath(typeof to === "string" ? to : to.pathname, params || {}); return /* @__PURE__ */ jsx( Navigate, { ...props, to: typeof to === "string" ? path : { pathname: path, search: to.search, hash: to.hash } } ); } }; }; export { components };