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

Handle null deps in hooks #1605

Merged
merged 3 commits into from
Jan 11, 2021
Merged

Handle null deps in hooks #1605

merged 3 commits into from
Jan 11, 2021

Conversation

karol-bisztyga
Copy link
Contributor

@karol-bisztyga karol-bisztyga commented Jan 8, 2021

Description

We don't handle the case when null is passed as dependencies in either useAnimatedGestureHandler or useAnimatedScrollHandler. Although in types it's not an option we have to consider that not all of the users use TypeScript.

Automatic casting to boolean works fine here as !![] === true.

example code
const gestureHandler = useAnimatedGestureHandler({
    onActive: (event, ctx) => {
        // ...
    },
  }, null);

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@karol-bisztyga karol-bisztyga merged commit bb38f94 into master Jan 11, 2021
@karol-bisztyga karol-bisztyga deleted the @karol/handle-null-deps branch January 11, 2021 13:19
rpavlovs pushed a commit to rpavlovs/react-native-reanimated that referenced this pull request Jan 12, 2021
## Description

We don't handle the case when `null` is passed as dependencies in either `useAnimatedGestureHandler` or `useAnimatedScrollHandler`. Although in types it's not an option we have to consider that not all of the users use TypeScript.

Automatic casting to boolean works fine here as `!![] === true`.

<details>
<summary>example code</summary>

```
const gestureHandler = useAnimatedGestureHandler({
    onActive: (event, ctx) => {
        // ...
    },
  }, null);
```

</details>

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
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

Successfully merging this pull request may close these issues.

None yet

2 participants