#lalilunar-paymentintent

1 messages · Page 1 of 1 (latest)

rustic wave
#

hello, what qs can we help answer

formal lynx
#

I tried to look for help on internet but nothing related to this on the docs, stack overflow, web in general

#

any help is appreciated please , thanks in advance

rustic wave
#

ah so useEffect() is being triggered twice?

formal lynx
#

is being triggered once but for some reason I can see that hit the api twice

#

even If I have an empty array dependency

#

is like setup_intent gived me the clientSecret and don't give any time to hit the api with that information and again hit the api asking for the same data

#

(different clientSecret, id)

rustic wave
#

can you put logs or breakpoint in your useEffect and confirm that it is being triggered multiple times

formal lynx
#

yes

#

I have a function outside the useEffect getSetupIntent() where I fetch this clientSecret and ID and I have this useEffect, inside I am executing getSetupIntent()

#

but when I console.log I can see that this function is being fired twice

#

The first time I hit the API should store the ID but because store this value would have some delay, the front-end hit the api for the 2nd time

#

so it interpret it as 2 new atemps

#

is there a way to delay this setup_intent or to conditionally execute ?

rustic wave
#

yeah so I'm not an expert at React but there's a way to limit the number of times useEffect() is called with a second optional parameter, you can look into that (there would be resources online) and try that because you mentioned useEffect() is being triggered twice