Skip to content

Commit

Permalink
Merge branch 'main' into test-utils/refactor/add-package
Browse files Browse the repository at this point in the history
manudeli authored Oct 24, 2023
2 parents ca075d2 + 744f3ac commit 3e88d45
Showing 12 changed files with 48 additions and 34 deletions.
7 changes: 7 additions & 0 deletions packages/react-query/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @suspensive/react-query

## 1.17.4

### Patch Changes

- Updated dependencies [70d8128]
- @suspensive/react@1.17.4

## 1.17.3

### Patch Changes
4 changes: 2 additions & 2 deletions packages/react-query/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@suspensive/react-query",
"version": "1.17.3",
"version": "1.17.4",
"description": "Useful helpers for @tanstack/react-query with suspense",
"keywords": [
"suspensive",
@@ -70,7 +70,7 @@
"tsd": "^0.28.1"
},
"peerDependencies": {
"@suspensive/react": "workspace:^1.17.3",
"@suspensive/react": "workspace:^1.17.4",
"@tanstack/react-query": "^4",
"react": "^16.8 || ^17 || ^18"
},
6 changes: 6 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @suspensive/react

## 1.17.4

### Patch Changes

- 70d8128: fix(react): convert Suspense.CSROnly's useEffect into useIsomorphicLayoutEffect to prevent unnecessary layout shift

## 1.17.3

### Patch Changes
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@suspensive/react",
"version": "1.17.3",
"version": "1.17.4",
"description": "Useful interfaces for React Suspense",
"keywords": [
"suspensive",
6 changes: 3 additions & 3 deletions packages/react/src/Suspense.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ComponentProps, ComponentType, ReactNode, SuspenseProps as ReactSuspenseProps } from 'react'
import { Suspense as ReactSuspense, createContext, useContext } from 'react'
import { useIsMounted } from './hooks'
import { useIsClient } from './hooks'
import type { PropsWithoutChildren } from './types'

export type SuspenseProps = ReactSuspenseProps
@@ -21,10 +21,10 @@ if (process.env.NODE_ENV !== 'production') {
DefaultSuspense.displayName = 'Suspense'
}
const CSROnlySuspense = (props: SuspenseProps) => {
const isMounted = useIsMounted()
const isClient = useIsClient()
const fallback = useFallbackWithContext(props.fallback)

return isMounted ? <ReactSuspense {...props} fallback={fallback} /> : <>{fallback}</>
return isClient ? <ReactSuspense {...props} fallback={fallback} /> : <>{fallback}</>
}
if (process.env.NODE_ENV !== 'production') {
CSROnlySuspense.displayName = 'Suspense.CSROnly'
2 changes: 1 addition & 1 deletion packages/react/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { useIsChanged } from './useIsChanged'
export { useIsMounted } from './useIsMounted'
export { useIsClient } from './useIsClient'
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
export { useKey } from './useKey'
export { usePrevious } from './usePrevious'
12 changes: 12 additions & 0 deletions packages/react/src/hooks/useIsClient.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { renderHook } from '@testing-library/react'
import { useIsClient } from '.'

describe('useIsClient', () => {
it('should return true when client side painting start', () => {
const {
result: { current: isClient },
} = renderHook(() => useIsClient())

expect(isClient).toBe(true)
})
})
12 changes: 12 additions & 0 deletions packages/react/src/hooks/useIsClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useState } from 'react'
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'

export const useIsClient = () => {
const [isClient, setIsClient] = useState(false)

useIsomorphicLayoutEffect(() => {
setIsClient(true)
}, [])

return isClient
}
12 changes: 0 additions & 12 deletions packages/react/src/hooks/useIsMounted.spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react/src/hooks/useIsMounted.ts

This file was deleted.

4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions websites/visualization/package.json
Original file line number Diff line number Diff line change
@@ -30,9 +30,9 @@
"@emotion/react": "^11.10.8",
"@emotion/styled": "^11.10.8",
"@jsxcss/emotion": "^1.3.9",
"@suspensive/react": "workspace:1.17.3",
"@suspensive/react": "workspace:1.17.4",
"@suspensive/react-await": "workspace:0.0.1",
"@suspensive/react-query": "workspace:1.17.3",
"@suspensive/react-query": "workspace:1.17.4",
"@tanstack/react-query": "^4.29.5",
"@tanstack/react-query-devtools": "^4.29.5",
"@vercel/analytics": "^1.1.1",

0 comments on commit 3e88d45

Please sign in to comment.