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
1.21k stars 293 forks source link

useState used with no setter #13

Open jdegand opened 2 months ago

jdegand commented 2 months 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 2 months ago

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