Skip to content

Commit

Permalink
useIsomorphicLayoutEffect export
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes committed Jun 25, 2024
1 parent 69a96dc commit eab299d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { useMediaQuery } from './useMediaQuery';
export { usePrevious } from './usePrevious';
export { useSynchronizedAnimation } from './useSynchronizedAnimation/useSynchronizedAnimation';
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Meta, Primary, ArgTypes } from '@storybook/blocks';

<Meta title='Hooks/useIsomorphicLayoutEffect' />

# useIsomorphicLayoutEffect

Hook som bruker enten `useLayoutEffect` eller `useEffect` avhengig av om det kjører på klienten eller serveren.

```tsx
useIsomorphicLayoutEffect(() => {
console.log(
'I nettleseren, er eg `useLayoutEffect`, men i SSR, er eg `useEffect`.',
);
}, []);
```
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// https://usehooks-ts.com/react-hook/use-isomorphic-layout-effect

import { useEffect, useLayoutEffect } from 'react';

export const useIsomorphicLayoutEffect =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { useRef } from 'react';

import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect';
import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';

/**
* Synchronizes the css animation of multiple elements with the same `animationName`.
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './components';
export { useSynchronizedAnimation } from './hooks';
export { useSynchronizedAnimation, useIsomorphicLayoutEffect } from './hooks';
2 changes: 2 additions & 0 deletions packages/react/src/utilities/RovingTabIndex/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Inspired by radix-ui https://github.com/radix-ui/primitives/blob/main/packages/react/roving-focus/README.md

export { RovingTabindexRoot } from './RovingTabindexRoot';
export { useRovingTabindex } from './useRovingTabindex';
export {
Expand Down

0 comments on commit eab299d

Please sign in to comment.