{"record":{"id":"ab05e0afa9db559a","repo":"facebook/react","slug":"react-hook-useeffect-requires-an-effect-callback","errorCode":null,"errorMessage":"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?","messagePattern":"React Hook useEffect requires an effect callback\\. Did you forget to pass a callback to the hook\\?","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/react/src/ReactHooks.js","lineNumber":93,"sourceCode":"  initialArg: I,\n  init?: I => S,\n): [S, Dispatch<A>] {\n  const dispatcher = resolveDispatcher();\n  return dispatcher.useReducer(reducer, initialArg, init);\n}\n\nexport function useRef<T>(initialValue: T): {current: T} {\n  const dispatcher = resolveDispatcher();\n  return dispatcher.useRef(initialValue);\n}\n\nexport function useEffect(\n  create: () => (() => void) | void,\n  deps: Array<mixed> | void | null,\n): void {\n  if (__DEV__) {\n    if (create == null) {\n      console.warn(\n        'React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?',\n      );\n    }\n  }\n\n  const dispatcher = resolveDispatcher();\n  return dispatcher.useEffect(create, deps);\n}\n\nexport function useInsertionEffect(\n  create: () => (() => void) | void,\n  deps: Array<mixed> | void | null,\n): void {\n  if (__DEV__) {\n    if (create == null) {\n      console.warn(\n        'React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?',\n      );","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react/src/ReactHooks.js#L75-L111","documentation":"The exported useEffect checks in dev that its first argument is not null/undefined before forwarding to the dispatcher (ReactHooks.js:93). An effect hook without a callback has nothing to schedule; the warning fires at call time, and if the undefined slips through to commit, React later crashes with 'create is not a function' (TypeError) inside commitHookEffectListMount.","triggerScenarios":"useEffect() called with no arguments; useEffect(undefined, [deps]); passing a conditionally-chosen callback (cond ? fn : undefined); passing a function call's result instead of the function, e.g. useEffect(fn(), deps).","commonSituations":"'Optional' effects written conditionally; refactors that rename or delete the callback but leave the hook call; typed-loose JS where the argument silently becomes undefined.","solutions":["Always pass the effect function: useEffect(() => {...}, [deps])","Keep the call unconditional and branch inside the callback when the effect is optional","Enable TypeScript/Flow checking and eslint-plugin-react-hooks so a missing argument fails CI, not runtime"],"exampleFix":"// before\nuseEffect(loggedIn ? loadProfile : undefined, [loggedIn]);\n\n// after\nuseEffect(() => {\n  if (loggedIn) loadProfile();\n}, [loggedIn]);","handlingStrategy":"validation","validationCode":"// dev assert before the hook (keeps the hook call unconditional)\nif (__DEV__ && typeof create !== 'function') {\n  throw new TypeError('useEffect requires an effect callback');\n}\nuseEffect(create, deps);","typeGuard":"const isEffectCallback = (x) => typeof x === 'function';","tryCatchPattern":null,"preventionTips":["Always pass a literal arrow function to effect hooks","Make optional effects branch inside the callback instead of passing undefined","Turn on strict TypeScript and eslint-plugin-react-hooks to catch missing arguments statically"],"tags":["hooks","use-effect","missing-argument","dev-only","common-mistake"],"backgroundTag":"missing-hook-argument","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}