useEffect infinite loop

I am inserting values into my db using useEffect but it causes infinite loop
10 Replies
barry
barry3y ago
You don’t… what? What are you trying, the code doesn’t make much sense, what problem are you solving
aditya
adityaOP3y ago
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
cje
cje3y ago
don't do this
aditya
adityaOP3y ago
then what should I do
cje
cje3y ago
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
aditya
adityaOP3y ago
what is a seedfile
cje
cje3y ago
Prisma
Seeding your database
Learn how to seed your database using Prisma's integrated seeding functionality and Prisma Client
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
aditya
adityaOP3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server