#.toFixed - Vercel Deployment Prerender error

17 messages · Page 1 of 1 (latest)

abstract linden
#

Hi! for some reason if I use .toFixed to ensure my coordinates (in lng,lat) are just 4 decimal places, it runs into a pre-render error in vercel during deployment. I already tried ensuring that the variables these are being applied to have a try-catch system to avoid being undefined but it still doesn't work. Any directions / help will be appreciated!

Error message:

Error occurred prerendering page "/components/Modal". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of undefined (reading 'toFixed')
    at i (/vercel/path0/v-mongo/.next/server/chunks/306.js:1:3133)
    at Wc (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at Zc (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:481)
    at Z (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at Zc (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:481)
    at Z (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
    at $c (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
    at bd (/vercel/path0/v-mongo/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)

   Generating static pages (6/13) 

   Generating static pages (9/13) 

 ✓ Generating static pages (13/13) 
> Export encountered errors on following paths:
    /components/Modal
Error: Command "npm run build" exited with 1
distant quailBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

craggy needle
#

and in this case your number or whatever u apply .ToFixed is undefined

abstract linden
#

hi ! thanks for responding ! May I ask what fix I can do to still be able to round the coordinates to 4 places without the pre-render error? I tried wrapping it with a try catch but to no avail D:. I also tried having a default state in my useState and still doesn't work

craggy needle
abstract linden
#

its from a database (mongoDB)

craggy needle
#

yeah and is that call in a rsc

#

server component

abstract linden
#

sorry for this, but may I ask how I'll know if its in a RSC?

craggy needle
#

everything without "use client" at the top and returning tsx

abstract linden
#

yea its in rsc. thanks for explaining!

craggy needle
#
export const dynamic = 'force-dynamic'
#

add this to your page.tsx where u are fetching your db

#

and try again

abstract linden
#

okay! ill try that for now and put back the .toFixed! thanks a lot!