Open
Description
Bug report
Description / Observed Behavior
The same code that worked with Expo 52 is not working with Expo 53
Repro Steps / Code Example
void createPost({
post: dto,
}, {
optimisticData: data && [{
...dto,
createdAt: now,
updatedAt: now,
userId: userId,
id: 'optimistic-id',
}, ...data],
rollbackOnError: true,
onError: (error) => {
console.error('Error creating post:', error);
},
});
export function useCreatePost(vacationId: string | null) {
const { mutate } = usePosts(vacationId);
return useSWRMutation(`/vacations/${vacationId}/posts`, createPost, {
onSuccess: (post) => mutate(addTrailing(post), false),
onError: (error) => console.error('Failed to create post:', error),
});
}
A console.log in a component that depends on posts reveals that it is not re-rendered until after the server-side mutation completes.
const { data: posts } = usePosts(vacationId);
console.log('rendered', posts?.length);
Additional Context
SWR version 2.3.3
Metadata
Metadata
Assignees
Labels
No labels