Searching...
}
- >
- )
-}
-```
-
-### Optimistic Updates
-
-Apply data changes instantly before the server responds, with automatic rollback on failure:
-
-
-```react
-import { router } from '@inertiajs/react'
-
-function like(post) {
- router.optimistic((props) => ({
- post: {
- ...props.post,
- likes: props.post.likes + 1,
- },
- })).post(`/posts/${post.id}/like`)
-}
-```
-
-Optimistic updates also work with `useForm` and the `
-
Dashboard
-
Active Users: {stats.activeUsers}
-
- )
-}
-```
-
-
-```react
-import { usePoll } from '@inertiajs/react'
-
-export default function Dashboard({ stats }) {
- const { start, stop } = usePoll(5000, {
- only: ['stats'],
- onStart() {
- console.log('Polling request started')
- },
- onFinish() {
- console.log('Polling request finished')
- },
- }, {
- autoStart: false,
- keepAlive: true,
- })
-
- return (
-