Skip to content

Empty tuple in useEffect deps #132

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

Closed
RabbitShare opened this issue Mar 23, 2025 · 2 comments
Closed

Empty tuple in useEffect deps #132

RabbitShare opened this issue Mar 23, 2025 · 2 comments

Comments

@RabbitShare
Copy link

Hello, I new in ReScript.
If I change useEffect deps from (1, 2) to () it's still compiled, but with logic errors (pass undefined to deps instead of empty array). It'is possible to discard empty tuple from deps?

Example https://rescript-lang.org/try?version=v11.1.4&module=esmodule&code=LYewJgrgNgpgBAQQA5LgXjgbwFBzgAQCcYBDAYwBcA6MkYJEAOxkYtzlgrmBIGt4MACgCU6AHxZ2eAEqlKVCAGcYAUQBmamJUEjxkvAbgA5JjClwAvgBo4I4dnMnm7C9ldA

@Freddy03h
Copy link
Collaborator

@cknitt
Copy link
Member

cknitt commented May 4, 2025

There is actually no "empty tuple" in ReScript. () is of type unit and compiles to undefined.

As an alternative to React.useEffect0, you pass an empty array like you do in JS: https://rescript-lang.org/try?version=v11.1.4&module=esmodule&code=LYewJgrgNgpgBAQQA5LgXjgbwFBzgAQCcYBDAYwBcA6MkYJEAOxkYtzlgrmBIGt4MACgCU6AHxZ2eAEqlKVCAGcYAUQBmamJUEjxkvAbgA5JjClwAvgBo4AbQC6w7OZPN2F7B6A

@cknitt cknitt closed this as completed May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants