-
Notifications
You must be signed in to change notification settings - Fork 33
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
Return ref of tween target #19
Comments
Hmm, the Tween needs the ref by his own and overwrites it in this case. I could try to first get the ref and set it with the new ref var. But why exactly you need it? |
I need the |
Ok let me try later. You also could get the refs with a tweenref.current.getGSAP().targets() call. Look here: https://bitworking.github.io/react-gsap/src-instructions-low-level-access |
I tried it but cannot set the ref, because it's readonly. I saw your lib (https://github.com/fitzmode/use-dynamic-refs). You perhaps can help me with this? I do the following, which probably could be optimized, too: https://github.com/bitworking/react-gsap/blob/master/packages/react-gsap/src/Tween.tsx#L204 React.Children.map(children, child => {
return React.cloneElement(child, {
ref: target => {
this.addTarget(target);
// this doesn't work and I don't know if
// setting the target to child.ref is the way to go
child.ref = target;
},
});
}) |
Let me work on it and will come back with a PR |
I found a solution: facebook/react#8873 (comment) Will be in next version. |
Fixed with version 2.3.0 |
Hey there. Seems Tween does not return the
ref
of it's children.Here's a demo https://codesandbox.io/s/wizardly-mclaren-7oswj?file=/src/App.js
The text was updated successfully, but these errors were encountered: