dconroy
TTCTheo's Typesafe Cult
•Created by dconroy on 7/1/2023 in #questions
Chirp: the trpc call to get all posts, hits the database every re-render....
Is this expected behavior? Or is the way Theo wrote placing the get all posts just as a demonstration, and that a real app would do something to get the data and only requery when it needs? Such as using useEffect to get it once and store it until change is needed?
In the index.tsx he has:
api.posts.getAll.useQuery();
A similar query is in the feed component as well.
I looked at planetscale's statistics page and sure enough it increments the count for the query to get all posts everytime the page rerenders, or even loses focus and regains it. There must be some caching going on since if you remove the line to .invalidate() after creating a new post, the get all query runs(and is counted on planetscale) but the new post doesn't appear in the feed.
So I'm not quite sure what's happening...if prisma or trpc is determining that a cached result is fine, why does it still hit planetscale? Seems like alot of unecessary trips to the db.
7 replies
TTCTheo's Typesafe Cult
•Created by dconroy on 5/5/2023 in #questions
t3 tutorial- chirp project...vercel build fails.
Following along with Theo's 2+hr video....got to the very first deployment to vercel. Project imports fine. Prisma db connection went fine. npm run build works fine locally...but...
Other than the database config from the tutorial, I've changed nothing in the app. Is there another config issue somewhere in Vercel? (Yes I added the env variable)
When vercel does a build to deploy:
info - Creating an optimized production build...
info - Compiled successfully
info - Collecting page data...
info - Generating static pages (0/6)
TypeError: Cannot read properties of null (reading 'useMemo')
at exports.useMemo (/vercel/path0/node_modules/react/cjs/react.production.min.js:25:208)
at Object.useDehydratedState (file:///vercel/path0/node_modules/@trpc/react-query/dist/createHooksInternal-ac3d45d9.mjs:517:29)
at WithTRPC (/vercel/path0/.next/server/chunks/34.js:101:38)
at Ge (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:114:273)
at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:91)
at Ge (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:115:9)
at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:91)
at He (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:123:155)
at Je (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:122:100)
at Z (/vercel/path0/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.browser.production.min.js:120:222)
6 replies