michaelshimeles / nextjs-starter-kit

The Ulimate Nextjs Starter Kit. Build your next SAAS product of your dreams. Batteries included.
https://starter.rasmic.xyz/
MIT License
842 stars 202 forks source link

useState used with no setter #13

Open jdegand opened 1 week ago

jdegand commented 1 week ago

Usually, this is a code smell.

In app/provider.tsx, you used const [queryClient] = useState(() => new QueryClient());.

The tanstack docs define the queryClient outside of the function.

const queryClient = new QueryClient()

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <Example />
    </QueryClientProvider>
  )
}

I think useRef could also be a potential solution.

michaelshimeles commented 6 days ago

that's correct, could you do a PR sir?