Open CSMR-DB opened 4 years ago
I had to look at this more deeply. Maybe this will be fixed with version 3, when I change the way how Timeline targets refs are added.
This is a hard one. Still not fixed in 3.1.0.
The problem is that the target change with every rerender. You can prevent this by using a useMemo hook:
const CurriedForwardedTimelineTargetMarkup: React.ForwardRefExoticComponent<React.RefAttributes<
any
>> = useMemo(() => CurriedForwardedTimelineTarget({ text }), [text]);
I'll mark this issue as enhancement and try to make it work with changing targets.
I have a few different Scenes constructed using their own Timelines and 1 master Timeline taking care of sequencing the different scenes. Every scene may or may not use a
forwardRef
markup as showcased in the Advanced Multiple Targets section. It looks something like this:This issue has to do with me currying props into
forwardRef
components. The manual control just completely breaks the sequence. However, when I use the providedControls
wrapper, all is fine. Makes me think that the curried forwardRef is not the issue per se. New CodeSandbox example: uncomment both theControl
tags to see what is happening.