Skip to content

Commit

Permalink
refactor(react/hooks): rename useIsMount & update useEffect to useIso…
Browse files Browse the repository at this point in the history
…morphicLayoutEffect
  • Loading branch information
minsoo-web committed Oct 20, 2023
1 parent 7694719 commit 7c0daf9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
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 { useIsCSROnly } from './useIsCSROnly'
export { useIsChanged } from './useIsChanged'
export { useIsMounted } from './useIsMounted'
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
export { useKey } from './useKey'
export { usePrevious } from './usePrevious'
Expand Down
12 changes: 12 additions & 0 deletions packages/react/src/hooks/useIsCSROnly.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { renderHook } from '@testing-library/react'
import { useIsCSROnly } from '.'

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

expect(isClient).toBe(true)
})
})
12 changes: 12 additions & 0 deletions packages/react/src/hooks/useIsCSROnly.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 useIsCSROnly = () => {
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.

0 comments on commit 7c0daf9

Please sign in to comment.