You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the preserveUrl: true option with the React adapter of Inertia.js, the URL is updated in the browser despite the option being set to preserve the current URL.
However, the same functionality works as expected in the Vue 3 adapter. This indicates a potential issue with the React adapter's implementation of the preserveUrl feature.
useInertia\Inertia;
class PreserveUrlDemoController extends Controller {
publicfunctionindex() {
return Inertia::render('PreserveUrlDemo', [
'message' => 'This is the Index Page',
]);
}
publicfunctionone() {
return Inertia::render('PreserveUrlDemo', [
'message' => 'This is Page One',
]);
}
}
React implementation:
importReactfrom'react';import{router}from'@inertiajs/react';exportdefaultfunctionPreserveUrlDemo({ message }){constnavigateToOne=()=>{router.visit(route('preserve-url-demo-1'),{method: 'get',preserveUrl: true,});};constnavigateToIndex=()=>{router.visit(route('preserve-url-demo'),{method: 'get',preserveUrl: false,});};return(<div><h1>{message}</h1><buttononClick={navigateToOne}>Go to Page One</button><buttononClick={navigateToIndex}>Go to Index Page</button></div>);}
When preserveUrl: true is set, the browser's URL should remain unchanged, and only the page content should update.
Actual behavior:
In the React environment:
The URL is updated in the browser even though preserveUrl is set to true.
In the Vue 3 environment:
The URL remains unchanged as expected, and the page content updates correctly.
Additional context:
No error messages appear in the browser console, and network requests are made as expected. However, the React adapter does not preserve the URL correctly.
The text was updated successfully, but these errors were encountered:
Version:
@inertiajs/react
: 2.0.0Describe the problem:
When using the
preserveUrl: true
option with the React adapter of Inertia.js, the URL is updated in the browser despite the option being set to preserve the current URL.However, the same functionality works as expected in the Vue 3 adapter. This indicates a potential issue with the React adapter's implementation of the
preserveUrl
feature.Steps to reproduce:
Backend:
Laravel routes:
Laravel controller:
React implementation:
Vue implementation (works correctly):
Expected behavior:
When
preserveUrl: true
is set, the browser's URL should remain unchanged, and only the page content should update.Actual behavior:
In the React environment:
preserveUrl
is set totrue
.In the Vue 3 environment:
Additional context:
No error messages appear in the browser console, and network requests are made as expected. However, the React adapter does not preserve the URL correctly.
The text was updated successfully, but these errors were encountered: