-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
X-Inertia-Version error #2252
Comments
@ldavidsp I have this exact problem! How did you resolve it? |
Hello @unyieldinggrace , I have solved it using useDebouncedCallback, I have applied this to the filters. I was using useForm(), but I changed to useState(). import { useDebouncedCallback } from 'use-debounce';
const [filters, setFilters] = useState({
name: name,
page: 1,
});
const debouncedSearch = useDebouncedCallback(newFilters => {
router.get(
route('brands.index'),
{ ...newFilters, page: 1 },
{ preserveState: true, replace: true },
);
}, 300);
useEffect(() => {
debouncedSearch(filters);
}, [filters, debouncedSearch]); render<input
name={'name'}
value={filters.name}
type={'text'}
onChange={event => {
setFilters({
...filters,
name: event.target.value,
page: 1,
});
}} /> |
Thanks for the info. I think I had the same error but for a different reason. I was trying to do a call to After digging through the inertia source code, here's what I learned. We can't call To get around this, I wrapped the parent element that initialises the router in another parent element (which I call
There is a
The page checks that global before calling the router, so that
Hopefully that helps someone! |
Version:
@inertiajs/react
version: 2.0.3Version error:
Steps to reproduce:
The text was updated successfully, but these errors were encountered: