Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: november 2024 #6445

Merged
merged 11 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(core): link component ref type is too restrictive (#6464) Resolves
alicanerdurmaz authored Nov 7, 2024
commit 98c7692a62c448e9c3cddac27d1924d925dc4c87
17 changes: 17 additions & 0 deletions .changeset/three-cameras-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@refinedev/core": patch
---

fix: Added more flexibility to the [`<Link />`](https://refine.dev/docs/routing/components/link/) component's `ref` type by changing it from `HTMLAnchorElement` to `Element`.
From now on, we can pass any type of `ref` to the [`<Link />`](https://refine.dev/docs/routing/components/link/) component.

```tsx
// Before fix - Only worked with HTMLAnchorElement
const ref = useRef<HTMLAnchorElement>(null);

// After fix - Works with any Element type
const ref = useRef<HTMLDivElement>(null);
const ref = useRef<HTMLSpanElement>(null);
```

Resolves [#6463](https://github.com/refinedev/refine/issues/6463)
1 change: 1 addition & 0 deletions documentation/docs/routing/components/link/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: <Link />
source: packages/core/src/components/link/index.tsx
---

`<Link />` is a component that is used to navigate to different pages in your application.
8 changes: 3 additions & 5 deletions packages/core/src/components/link/index.tsx
Original file line number Diff line number Diff line change
@@ -13,9 +13,7 @@ type LinkPropsWithTo = {
};

export type LinkProps<TProps = {}> = React.PropsWithChildren<
(LinkPropsWithGo | LinkPropsWithTo) &
React.AnchorHTMLAttributes<HTMLAnchorElement> &
TProps
(LinkPropsWithGo | LinkPropsWithTo) & TProps
>;

/**
@@ -25,7 +23,7 @@ export type LinkProps<TProps = {}> = React.PropsWithChildren<
*/
const LinkComponent = <TProps = {}>(
props: LinkProps<TProps>,
ref: Ref<HTMLAnchorElement>,
ref: Ref<Element>,
) => {
const routerContext = useContext(RouterContext);
const LinkFromContext = routerContext?.Link;
@@ -70,5 +68,5 @@ const LinkComponent = <TProps = {}>(
};

export const Link = forwardRef(LinkComponent) as <T = {}>(
props: LinkProps<T> & { ref?: Ref<HTMLAnchorElement> },
props: LinkProps<T> & { ref?: Ref<Element> },
) => ReturnType<typeof LinkComponent>;