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

feat: Allow a ref to be undefined in the types #33

Merged
merged 2 commits into from
Sep 28, 2023
Merged

feat: Allow a ref to be undefined in the types #33

merged 2 commits into from
Sep 28, 2023

Conversation

skvale
Copy link
Contributor

@skvale skvale commented Sep 14, 2023

Thanks for the library!

Summary

I use react-merge-refs for optional refs that may or may not be passed into a component:

const mergedRef = mergeRefs([inputProps?.ref, localRef]);

This functionally works, but it shows a type error

Type 'undefined' is not assignable to type 'LegacyRef | MutableRefObject'.

Test plan

The included test checks the types are correct as well as the behavior when passing null or undefined to mergeRefs

Copy link
Owner

@gregberge gregberge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this addition. Could you please allow null value and run npm run format to fix the formatting?

@skvale
Copy link
Contributor Author

skvale commented Sep 21, 2023

How does b877f71 look?

@gregberge gregberge merged commit d9079dd into gregberge:main Sep 28, 2023
1 check passed
@gregberge
Copy link
Owner

@skvale released!

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.

3 participants