Skip to content

Bug: [React 19] [Regression] Unexpected TypeError when useEffect returns null — "destroy is not a function" in React 19.x (cleanup now stricter) #35193

@Darshan-Naik

Description

@Darshan-Naik

Bug: [React 19] [Regression] Unexpected TypeError when useEffect returns null — "destroy is not a function" in React 19.x (cleanup now stricter)

Summary

After upgrading to React 19.x, code that previously returned null from a useEffect callback now throws TypeError: destroy is not a function during cleanup. Previously returning null or other non-function values often worked. This appears to be stricter runtime enforcement of the rule that an effect may only return a cleanup function or nothing.

Reproduction (minimal)

import React, { useEffect } from "react";

export default function App() {
  useEffect(() => {
    // early exit path that used to return null
    if (Date.now() < 0) {
      return null;
    }
    // normal effect (no cleanup)
    console.log("effect ran");
  }, []);

  return <div>Test</div>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions