Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug: Poor error message when useEffect is called with no parameters #32354

Closed
JoshuaKGoldberg opened this issue Feb 11, 2025 · 0 comments · Fixed by #32355
Closed

Bug: Poor error message when useEffect is called with no parameters #32354

JoshuaKGoldberg opened this issue Feb 11, 2025 · 0 comments · Fixed by #32355
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Feb 11, 2025

React version: 19.0.0

Steps To Reproduce

  1. Call useEffect() - note the lack of arguments

Link to code example:

The current behavior

Uncaught TypeError: create is not a function
    at react-stack-bottom-frame (react-dom-client.development.js:22509:20)
    at runWithFiberInDEV (react-dom-client.development.js:543:16)
    at commitHookEffectListMount (react-dom-client.development.js:10758:29)
    at commitHookPassiveMountEffects (react-dom-client.development.js:10878:11)
    at reconnectPassiveEffects (react-dom-client.development.js:12802:11)
    at recursivelyTraverseReconnectPassiveEffects (react-dom-client.development.js:12774:9)
    at reconnectPassiveEffects (react-dom-client.development.js:12849:11)
    at doubleInvokeEffectsOnFiber (react-dom-client.development.js:15696:13)
    at runWithFiberInDEV (react-dom-client.development.js:543:16)
    at recursivelyTraverseAndDoubleInvokeEffectsInDEV (react-dom-client.development.js:15656:17)
    at commitDoubleInvokeEffectsInDEV (react-dom-client.development.js:15705:7)
    at flushPassiveEffects (react-dom-client.development.js:15470:13)
    at eval (react-dom-client.development.js:15324:11)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:44:48)

The expected behavior

Ideally not crash - or crash with a better error message?

In #15197 the reviews seemed to pointed towards a dev-only warning, rather than an invariant.


Re-opening of #15194 because the stalebot closed it.

@JoshuaKGoldberg JoshuaKGoldberg added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Feb 11, 2025
@poteto poteto closed this as completed in 192555b Feb 11, 2025
github-actions bot pushed a commit that referenced this issue Feb 11, 2025
## Summary

Fixes #32354.

Re-creation of #15197: adds a dev-only warning if `create == null` to
the three `use*Effect` functions:

* `useEffect`
* `useInsertionEffect`
* `useLayoutEffect`

Updates the warning to match the same text given in the
`react/exhaustive-deps` lint rule.

## How did you test this change?

I applied the changes manually within `node_modules/` on a local clone
of
https://github.com/JoshuaKGoldberg/repros/tree/react-use-effect-no-arguments.

Please pardon me for opening a PR addressing a not-accepted issue. I was
excited to get back to #15194 -> #15197 now that I have time. 🙂

---------

Co-authored-by: lauren <poteto@users.noreply.github.com>

DiffTrain build for [192555b](192555b)
github-actions bot pushed a commit that referenced this issue Feb 11, 2025
## Summary

Fixes #32354.

Re-creation of #15197: adds a dev-only warning if `create == null` to
the three `use*Effect` functions:

* `useEffect`
* `useInsertionEffect`
* `useLayoutEffect`

Updates the warning to match the same text given in the
`react/exhaustive-deps` lint rule.

## How did you test this change?

I applied the changes manually within `node_modules/` on a local clone
of
https://github.com/JoshuaKGoldberg/repros/tree/react-use-effect-no-arguments.

Please pardon me for opening a PR addressing a not-accepted issue. I was
excited to get back to #15194 -> #15197 now that I have time. 🙂

---------

Co-authored-by: lauren <poteto@users.noreply.github.com>

DiffTrain build for [192555b](192555b)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant