Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 684 Bytes

client-flush-effects.md

File metadata and controls

24 lines (18 loc) · 684 Bytes

useFlushEffects can not be called on the client

Why This Error Occurred

The useFlushEffects hook was executed while rendering a component on the client, or in another unsupported environment.

Possible Ways to Fix It

The useFlushEffects hook can only be called while server rendering a client component. As a best practice, we recommend creating a wrapper hook:

// lib/use-style-libraries.js
import { useFlushEffects } from 'next/streaming'

export default function useStyleLibraries() {
  if (typeof window === 'undefined') {
    // eslint-disable-next-line react-hooks/rules-of-hooks
    useFlushEffects([
      /* ... */
    ])
  }
  /* ... */
}