Skip to content

Conversation

li-jia-nan
Copy link

Summary

  • This PR adds a development-only warning to useEffectEvent to help developers catch incorrect usage.
    Currently, if a non-function value is passed as the callback argument, the runtime behavior is undefined. While Flow/TypeScript enforces the type in typed code, untyped JavaScript users may accidentally pass the wrong value.
  • With this change, in DEV mode React will emit a warning if the callback is not a function. This is consistent with other React hooks (e.g. useEffect) that validate arguments in development for a better developer experience, while remaining a no-op in production.

How did you test this change?

  • Ran yarn test to ensure the full test suite passes with no regressions.
  • Verified locally that the warning message appears in the console in development builds, and that no additional code is included in production builds.
  • Ran yarn lint, yarn flow, and yarn prettier to confirm formatting and type checks all pass.

@meta-cla meta-cla bot added the CLA Signed label Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant