Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add error message for useRecoilCallback() misuse #870

Closed

Conversation

drarmstr
Copy link
Contributor

@drarmstr drarmstr commented Feb 3, 2021

Summary:
Add a slightly better error message when useRecoilCallback() is misused when a user calls it with a function that just returns a value instead a function that takes the callback interface and returns a function that matches the signature of the callback we are producing.

Before: Uncaught TypeError: fn(...) is not a function
After: Uncaught Error: useRecoilCallback() accepts a function parameter which returns a function that matches the signature of the callback function.

Flow and TypeScript will catch this, but this runtime check may help those not using a type system. (#851)

Differential Revision: D26219475

Summary:
Add a slightly better error message when `useRecoilCallback()` is misused when a user calls it with a function that just returns a value instead a function that takes the callback interface and returns a function that matches the signature of the callback we are producing.

Before: `Uncaught TypeError: fn(...) is not a function`
After: `Uncaught Error: useRecoilCallback() accepts a function parameter which returns a function that matches the signature of the callback function.`

Flow and TypeScript will catch this, but this runtime check may help those not using a type system. (facebookexperimental#851)

Differential Revision: D26219475

fbshipit-source-id: 918150332c36435f99027f3b4841c881216875ca
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported labels Feb 3, 2021
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D26219475

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 3d6fb75.

@drarmstr drarmstr deleted the export-D26219475 branch April 12, 2021 20:00
AlexGuz23 pushed a commit to AlexGuz23/Recoil that referenced this pull request Nov 3, 2022
Summary:
Pull Request resolved: facebookexperimental/Recoil#870

Add a slightly better error message when `useRecoilCallback()` is misused when a user calls it with a function that just returns a value instead a function that takes the callback interface and returns a function that matches the signature of the callback we are producing.

Before: `Uncaught TypeError: fn(...) is not a function`
After: `Uncaught Error: useRecoilCallback() accepts a function parameter which returns a function that matches the signature of the callback function.`

Flow and TypeScript will catch this, but this runtime check may help those not using a type system. (#851)

Reviewed By: davidmccabe

Differential Revision: D26219475

fbshipit-source-id: 7d19cbad36fe4f46b2d14e4fdd3efcfce20eb450
snipershooter0701 pushed a commit to snipershooter0701/Recoil that referenced this pull request Mar 5, 2023
Summary:
Pull Request resolved: facebookexperimental/Recoil#870

Add a slightly better error message when `useRecoilCallback()` is misused when a user calls it with a function that just returns a value instead a function that takes the callback interface and returns a function that matches the signature of the callback we are producing.

Before: `Uncaught TypeError: fn(...) is not a function`
After: `Uncaught Error: useRecoilCallback() accepts a function parameter which returns a function that matches the signature of the callback function.`

Flow and TypeScript will catch this, but this runtime check may help those not using a type system. (#851)

Reviewed By: davidmccabe

Differential Revision: D26219475

fbshipit-source-id: 7d19cbad36fe4f46b2d14e4fdd3efcfce20eb450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants