You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common pitfall mentioned in the docs is this one by re-creating an object as part of a key:
useSWR(['/api/user', { id }], query)
I think this could be easily caught by an ESLint rule so I thought of creating one (It would even include a fix to convert it to a regular param, and add function instead of query like this:
-useSWR(['/api/user', { id }], query)+useSWR(['/api/user', id], (key, id) => query(key, { id }))
Do you have any other ideas for swr specific rules?
The package would be called eslint-plugin-swr if you do not mind?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
A common pitfall mentioned in the docs is this one by re-creating an object as part of a key:
useSWR(['/api/user', { id }], query)
I think this could be easily caught by an ESLint rule so I thought of creating one (It would even include a fix to convert it to a regular param, and add function instead of
query
like this:Do you have any other ideas for swr specific rules?
The package would be called
eslint-plugin-swr
if you do not mind?Beta Was this translation helpful? Give feedback.
All reactions