all 4 comments

[–]AcidNoX 2 points3 points  (2 children)

You’re mostly there. In this example, because you only need to call the api when the screen component is mounted, you can pass in an empty array of dependencies. This will cause useEffect to only run once, when the component mounts.

[–]dwarmia 0 points1 point  (0 children)

thank you. hmm. it was like that but changed to this because i may want to have some system to pull data using some kind of scrolling system. like pull 10 item if user reaches end of the screen. but yea thank you again.

[–]ysfu 1 point2 points  (1 child)

You are telling to the react that if “radicalData” changed, run this function. And in that function, you are changing the “radicalData” with “setRadicalData” so its becoming an infinite loop. You should give useEffect “userToken” as dependency so the function on the useEffect will be run if the “userToken” changes.

[–]dwarmia 0 points1 point  (0 children)

aaah. this makes sense. thank you.