Open girardinsamuel opened 1 month ago
After digging further, it might be the same issue as #1890. Calling router.reload()
from useEffect()
hook might be the issue here ?
@girardinsamuel this is a known issue, I don't know how we can fix that. I think is some small error when setting the currentPage in Inertia React implementation, a hot fix for that is use a setTimeout.
import { useEffect, useState } from "react";
import { router, usePage } from "@inertiajs/react";
function MyPage({ products = [] }) {
useEffect(() => {
setTimeout(() => {
router.reload({ only: ["products"] });
}, 0);
}, []);
return <div>...</div>;
}
More info:
Version:
@inertiajs/react
version: 1.2.0django-inertia
version: 0.6.0Describe the problem:
When using partial reload in a page component in React, I cannot manage to get the updated prop value.
In the following example,
products
prop is not loaded at initial page load because I am usinglazy
prop on server side. It initiates a second partial page reload with onlyproducts
prop. From networking tab, I can see it's working. But I don't know how to fetch this new prop value I get with the partial reload.Any clue ?
Steps to reproduce:
It might not be a bug but just a misuse on my side...the products value might not be updated because I have destructured it ?
Thank you very much in advance.