Link Component blocking server actions call ?
Unanswered
Jersey Wooly posted this in #help-forum
Original message was deleted.
2 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
Jersey Wooly
async function fetchWishes(wishlistId: string) {
const response = await getAllWishes(wishlistId); // Server actions blocking ??
if (!response.isSuccessful) {
toast({...});
return [];
}
return response.data;
}
export default function WishesList({ wishlistId }: WishesListProps) {
const [loading, setLoading] = useState<boolean>(true);
const [wishes, setWishes] = useState<TWish[]>([]);
useEffect(() => {
const fetchData = async () => {
try {
// call to the blocking function
const fetchedWishes = await fetchWishes(wishlistId);
setWishes(fetchedWishes);
} catch (error) {
toast({...});
} finally {
setLoading(false);
}
};
fetchData();
}, []);
return (
<>
{!loading ? (
wishes?.length > 0 ? (
wishes.map((wish) => (...)
) : (
<div className="...">
<p className="...">
Start adding wishes now! 🌟
</p>
</div>
)
) : (
<SkeletonPage />
)}
</>
)
}
The first Picture is when I use the Link to navigate between my routes, the
setLoading(false)
is never set cause the server actions is called but is indefinitely waiting![Image](https://cdn.discordapp.com/attachments/1193241275160350920/1193243687019364506/Screenshot_6.png?ex=65ac01c8&is=65998cc8&hm=963dbbf71b22954798c1eae8025067008993f96ac13a439a9596267f2e32916f&)
![Image](https://cdn.discordapp.com/attachments/1193241275160350920/1193243687354900581/Screenshot_7.png?ex=65ac01c8&is=65998cc8&hm=969de70e5bb7907a0a41fa30019bd6a5f317e11f8581495842e0b32d48871db4&)
The second pic is when I directly use an anchor tag instead to navigate