@inertiajs/react
Advanced tools
+19
-16
@@ -1111,9 +1111,13 @@ // src/index.ts | ||
| onBeforeNextRequest: () => setLoadingNext(true), | ||
| onCompletePreviousRequest: () => { | ||
| onCompletePreviousRequest: ({ completed }) => { | ||
| setLoadingPrevious(false); | ||
| syncStateFromDataManager(); | ||
| if (completed) { | ||
| syncStateFromDataManager(); | ||
| } | ||
| }, | ||
| onCompleteNextRequest: () => { | ||
| onCompleteNextRequest: ({ completed }) => { | ||
| setLoadingNext(false); | ||
| syncStateFromDataManager(); | ||
| if (completed) { | ||
| syncStateFromDataManager(); | ||
| } | ||
| }, | ||
@@ -1472,17 +1476,16 @@ onDataReset: syncStateFromDataManager | ||
| }) { | ||
| const pollRef = useRef5( | ||
| router7.poll(interval, requestOptions, { | ||
| ...options, | ||
| autoStart: false | ||
| }) | ||
| ); | ||
| const latest = useRef5(requestOptions); | ||
| latest.current = requestOptions; | ||
| const pollRef = useRef5(null); | ||
| useEffect10(() => { | ||
| if (options.autoStart ?? true) { | ||
| pollRef.current.start(); | ||
| } | ||
| return () => pollRef.current.stop(); | ||
| pollRef.current = router7.poll( | ||
| interval, | ||
| typeof requestOptions === "function" ? () => latest.current() : requestOptions, | ||
| { ...options, autoStart: options.autoStart ?? true } | ||
| ); | ||
| return () => pollRef.current?.destroy(); | ||
| }, []); | ||
| return { | ||
| stop: pollRef.current.stop, | ||
| start: pollRef.current.start | ||
| stop: () => pollRef.current?.stop(), | ||
| start: () => pollRef.current?.start() | ||
| }; | ||
@@ -1489,0 +1492,0 @@ } |
+19
-16
@@ -1117,9 +1117,13 @@ "use strict"; | ||
| onBeforeNextRequest: () => setLoadingNext(true), | ||
| onCompletePreviousRequest: () => { | ||
| onCompletePreviousRequest: ({ completed }) => { | ||
| setLoadingPrevious(false); | ||
| syncStateFromDataManager(); | ||
| if (completed) { | ||
| syncStateFromDataManager(); | ||
| } | ||
| }, | ||
| onCompleteNextRequest: () => { | ||
| onCompleteNextRequest: ({ completed }) => { | ||
| setLoadingNext(false); | ||
| syncStateFromDataManager(); | ||
| if (completed) { | ||
| syncStateFromDataManager(); | ||
| } | ||
| }, | ||
@@ -1472,17 +1476,16 @@ onDataReset: syncStateFromDataManager | ||
| }) { | ||
| const pollRef = (0, import_react16.useRef)( | ||
| import_core8.router.poll(interval, requestOptions, { | ||
| ...options, | ||
| autoStart: false | ||
| }) | ||
| ); | ||
| const latest = (0, import_react16.useRef)(requestOptions); | ||
| latest.current = requestOptions; | ||
| const pollRef = (0, import_react16.useRef)(null); | ||
| (0, import_react16.useEffect)(() => { | ||
| if (options.autoStart ?? true) { | ||
| pollRef.current.start(); | ||
| } | ||
| return () => pollRef.current.stop(); | ||
| pollRef.current = import_core8.router.poll( | ||
| interval, | ||
| typeof requestOptions === "function" ? () => latest.current() : requestOptions, | ||
| { ...options, autoStart: options.autoStart ?? true } | ||
| ); | ||
| return () => pollRef.current?.destroy(); | ||
| }, []); | ||
| return { | ||
| stop: pollRef.current.stop, | ||
| start: pollRef.current.start | ||
| stop: () => pollRef.current?.stop(), | ||
| start: () => pollRef.current?.start() | ||
| }; | ||
@@ -1489,0 +1492,0 @@ } |
+2
-2
| { | ||
| "name": "@inertiajs/react", | ||
| "version": "2.3.23", | ||
| "version": "2.3.24", | ||
| "license": "MIT", | ||
@@ -65,3 +65,3 @@ "description": "The React adapter for Inertia.js", | ||
| "lodash-es": "^4.18.1", | ||
| "@inertiajs/core": "2.3.23" | ||
| "@inertiajs/core": "2.3.24" | ||
| }, | ||
@@ -68,0 +68,0 @@ "scripts": { |
| import { PollOptions, ReloadOptions } from '@inertiajs/core'; | ||
| export default function usePoll(interval: number, requestOptions?: ReloadOptions, options?: PollOptions): { | ||
| stop: VoidFunction; | ||
| start: VoidFunction; | ||
| export default function usePoll(interval: number, requestOptions?: ReloadOptions | (() => ReloadOptions), options?: PollOptions): { | ||
| stop: () => void | undefined; | ||
| start: () => void | undefined; | ||
| }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
354321
0.43%3531
0.17%+ Added
- Removed
Updated