ui
ui copied to clipboard
Export pattern causes warning from `eslint-plugin-react-refresh`
After initializing in a new React Vite TS Storybook starter, that happened to have this eslint plugin installed, I get warnings on a number of files that export functions in addition to a component.
Also, although documentation about "Fast Refresh" is a bit scant unfortunately, some resources on it also say that each export requires its own export statement...
https://github.com/ArnaudBarre/eslint-plugin-react-refresh
...from my eslint config:
{
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
same issue here, any updates?
I would also prefer that there were no warnings.
It was surprising that this hasn't been a major issue, but it seems that most of the components provided by shadcn/ui are following the only-export-components rule. The only example of rule violation I found was with the button. Additionally, I don't think the button needs to export the buttonVariants function. I have removed the buttonVariants function from the export object in the installed button.tsx.
I found out that button is required to export buttonVariants due to dependencies from components such as alert-dialog. To adhere to the only-export-components rule, I decided to define buttonVariables in a file other than button.tsx and import them into button.tsx.
This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.
Just came across this myself, maybe its worth considering re-opening?
Same issue here in form when exporting useFormField
Same issue here in
formwhen exportinguseFormField
@GuillemPM For my use, I removed the useFormField as an export from the file. It is only being used internally by the other Form components. So unless you are using the useFormField hook somewhere in your code, removing it from the export list should solve the issue.
Would be great if this was looked at again.