inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.02k stars 405 forks source link

React: useForm Options - Replace History #1904

Closed imnash21 closed 1 week ago

imnash21 commented 1 week ago

I installed Laravel + InertiaJS yesterday (June 22, 2024).

The replace option in useForm hook not working properly.

"/" (Landing Page) <- This is my starting point.

"/login" (Login Page) <- My second point.

"/dashboard" (Dashboard Page) <- My third point, after the POST request.

In form:

const form = useForm(...)

const handleSubmit: React.FormEventHandler = (e) => { e.preventDefault()

form.post('/login', {
    replace: true,
})

}

At the controller:

public function login(Request $request) { ........... ..... ........

 return to_route('dashboard')

}

After redirected to dashboard page, then when I clicked the back button twice, it will go back to login page not to landing page.