You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is the runPython function isn't memoized, so it gets re-defined on each hook call. This causes useEffect to get triggered in an infinite loop.
Any reason for passing the runPython function as a dependency to your useEffect? TIL. Will make this change when I next have a moment to do so, otherwise feel free to open a PR.
Yeah, I've removed it for now to fix this issue, but it requires disabling a lint rule, which isn't ideal. Not a blocker / urgent, but guessing others will run into this as well, so just a suggestion!
I may be using the
usePython
hook differently than you intend, but it's currently causing an infinite loop for me.I have code like:
The problem is the
runPython
function isn't memoized, so it gets re-defined on each hook call. This causesuseEffect
to get triggered in an infinite loop.I think (?) the fix is to wrap
runPython
in auseCallback
where you define it here:https://github.com/elilambnz/react-py/blob/main/src/hooks/usePython.ts#L180
You may want to consider doing this for other functions your hooks return, so they won't change for callers on every render.
The text was updated successfully, but these errors were encountered: