jotai
jotai copied to clipboard
Issue: urql.atomWithMutation causes suspense on load
Any component that uses an atom that is using atomWithMutation will cause a suspense fallback to be rendered and will stay rendered indefinitely (maybe it clears on mutation, but I can't see the UI to get the mutation to go).
My atom:
export const saveSearchHistoryAtom = atomWithMutation<IAddSearchHistoryMutation, IAddSearchHistoryMutationVariables>(
(get)=> AddSearchHistoryDocument,
(get) => get(urqlClientAtom)
)
Component:
function SearchRecentlyViewed() {
const [saveSearchResp, saveSearchHistory] = useAtom(saveSearchHistoryAtom )
....
}
Nice catch. I didn't know what behavior is expected. What should the the initial value if we don't suspend? Feel free to also try playing with the urql.atomWithMutation impl.
Now, I think, it should be null
. I'll work on it some time later.
#1473 will solve this with providing a non-suspense api.