useEffect infinite loop
I am inserting values into my db using useEffect but it causes infinite loop

10 Replies
You don’t… what? What are you trying, the code doesn’t make much sense, what problem are you solving
i have some data in a js file i want to insert it into my db
so i am looping over the data one by one and inserting into db
the problem is the code in useEffect runs again and again
filling up the db w duplicate data
i want to run it only once
i tried to add this code to the onClick of a button but that doesn't work so thats why im using useEffect
don't do this
then what should I do
if you just need to do this once, use a seedfile or something
if you need it to happen on a page, figure out how to do it from an event handler or similar
this is not what useEffect is for
what is a seedfile
Prisma
Seeding your database
Learn how to seed your database using Prisma's integrated seeding functionality and Prisma Client
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
thanks really helpful
these doesn't seem to be any function calls
if i do this there's an error
invalid prisma create invocation
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View