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
Async createMemo with pagination keeps re-running when nextCursor is updated from the fetched result
Description
I'm testing the async createMemo behavior in Solid 2.0.
I have a paginated API where each response contains a nextCursor. The cursor is stored in a signal and is also used as a dependency of an async createMemo.
After each request, I update the cursor with the nextCursor returned by the API.
So simply reading the first result ends up fetching all pages until the API returns nextCursor: null.
Question
Is this the expected behavior for async createMemo in Solid 2.0?
I understand that cursor() becomes a reactive dependency of the memo, so from the fine-grained reactivity perspective the reruns make sense.
However, since Solid 2.0 encourages using async createMemo directly for data fetching, I'm wondering whether updating a pagination signal as a consequence of the same request is expected to recursively invalidate the memo in this way.
Should pagination state instead always be updated outside of the memo, for example in response to an explicit "Next page" action?
Or is there a recommended Solid 2.0 pattern for this type of cursor-based pagination?
Expected behavior / clarification requested
I'm mainly looking for clarification on whether:
This recursive request behavior is intentional and expected.
Updating reactive state from an async memo that is also one of the memo's dependencies should be avoided.
There is a recommended pattern in Solid 2.0 for cursor-based pagination using async createMemo.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Async
createMemowith pagination keeps re-running whennextCursoris updated from the fetched resultDescription
I'm testing the async
createMemobehavior in Solid 2.0.I have a paginated API where each response contains a
nextCursor. The cursor is stored in a signal and is also used as a dependency of an asynccreateMemo.After each request, I update the cursor with the
nextCursorreturned by the API.Something similar to:
Because
cursor()is read inside the memo, changing it after the request causes the memo to run again.As a result, the behavior becomes:
So simply reading the first result ends up fetching all pages until the API returns
nextCursor: null.Question
Is this the expected behavior for async
createMemoin Solid 2.0?I understand that
cursor()becomes a reactive dependency of the memo, so from the fine-grained reactivity perspective the reruns make sense.However, since Solid 2.0 encourages using async
createMemodirectly for data fetching, I'm wondering whether updating a pagination signal as a consequence of the same request is expected to recursively invalidate the memo in this way.Should pagination state instead always be updated outside of the memo, for example in response to an explicit "Next page" action?
Or is there a recommended Solid 2.0 pattern for this type of cursor-based pagination?
Expected behavior / clarification requested
I'm mainly looking for clarification on whether:
createMemo.Environment
All reactions