oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.02k stars 47 forks source link

Forwarding `ref` to Link component #172

Closed yverby closed 2 months ago

yverby commented 2 months ago

Using Link component (from @generouted/react-router package) as a dynamic component for other UI library components (e.g. @mui/joy) causes the following errors:

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

This can be fixed locally in a project, but it does not seem convenient if you need to override it in every project. Would it be possible to wrap Link component using React.forwardRef by default in the package?

Example: https://stackblitz.com/edit/github-wjvkrc-ibq3hw?file=src%2Fpages%2F_app.tsx

oedotme commented 2 months ago

@yverby Thanks for reporting.

I've included that change at the v1.19.6 release.

Here's the example updated: https://stackblitz.com/edit/github-wjvkrc-qzmcqe?file=src%2Fpages%2F_app.tsx