Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "http-react",
"version": "2.9.7",
"version": "2.9.8",
"description": "React hooks for data fetching",
"main": "dist/index.js",
"scripts": {
Expand Down
10 changes: 4 additions & 6 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FetchContextType } from '../types'

import { isDefined, serialize } from '../utils/shared'

let isServer: boolean
let isServer: boolean = true
/**
* This is a wrapper around `Suspense`. It will render `fallback` during the first render and then leave the rendering to `Suspense`. If you are not using SSR, you should continue using the `Suspense` component.
*/
Expand All @@ -26,13 +26,11 @@ export function SSRSuspense({
fallback?: React.ReactNode
children?: React.ReactNode
}) {
const [ssr, setSSR] = useState(isDefined(isServer) ? isServer : true)
const [ssr, setSSR] = useState(isServer)

useEffect(() => {
if (!isDefined(isServer)) {
setSSR(false)
isServer = false
}
setSSR(false)
isServer = false
}, [])

// This will render the fallback in the server
Expand Down
8 changes: 8 additions & 0 deletions src/hooks/use-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,14 @@ export function useFetch<FetchDataType = any, BodyType = any>(
suspenseInitialized[resolvedKey] = true
}
}
useEffect(() => {
if (url !== '') {
if (!jsonCompare(previousProps[resolvedKey], optionsConfig)) {
abortControllers[resolvedKey]?.abort()
queue(initializeRevalidation)
}
}
}, [serialize(optionsConfig)])

if (suspense) {
if (auto) {
Expand Down