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

(fix) - call function when ref is one #2021

Merged
merged 2 commits into from
Oct 18, 2019

Conversation

JoviDeCroock
Copy link
Member

fixes: #2020 (--> next year am I right?)

@@ -142,7 +142,8 @@ export function useImperativeHandle(ref, createHandle, args) {

function bindHandles(handles) {
handles.some(handle => {
if (handle.ref) handle.ref.current = handle.createHandle();
if (typeof handle.ref === 'function') handle.ref(handle.createHandle());
else if (handle.ref) handle.ref.current = handle.createHandle();
Copy link
Member

Choose a reason for hiding this comment

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

FYI: This looks pretty similar to applyRef in core. There is potential for golfing in the PR where hooks are merged into core 🎉

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 99.769% when pulling 1c3d53b on fix/useImperativeHandleWithFunc into 3143075 on master.

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.

useImperativeHandle function isn't invoked after first render
4 participants