Skip to content

recoil async selector cause infinite loop call #2014

Answered by drarmstr
LOGANLEEE asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like there is an infinite loop here because when the fetchHospitalAccount selector is updated then it will set the hospitalAtom to a new object instance. But, fetchHospitalAccount subscribes to hospitalAtom so it will then re-evaluate thus causing your infinite loop.

If fetchHospitalAccount is intended to query based on the current idx from hospitalAtom then it should not try to go back and update it via a useEffect().

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@LOGANLEEE
Comment options

Answer selected by LOGANLEEE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2007 on September 16, 2022 22:44.