Replies: 1 comment
-
let panelsAtom = focusAtom(currentPageAtom, (optic) => optic.prop("panels")); This creates a new atom on every render which results in the infinite loop. Either make the 2nd argument stable (by moving the function out of the component) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
HI,
I'm not sure how to do this, and I think the way I'm trying to do it is causing infinite recursion. Let's say I have some data that looks like this:
I have tried creating the atoms and focusAtoms this way:
and then I want to do something like this:
where the current page can change, and that change is tracked with the
pageIndex
.This isn't working. I'm getting several type errors, and my page is stuck in an infinite loop. I think it's because of the
atomPages[pageIndex]
becauseatomPages[pageIndex]
might be creating a new atom in the render, but I'm not sure. I'm somewhat new to his library and managing state in React in general. Any suggestions?Beta Was this translation helpful? Give feedback.
All reactions