You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the React renderer with precompiled tokens. The tokenization, serialization, and rendering all seem to work fine, but the transitions are all immediate, not animated.
This may appear as a duplicate of React example not working #32, but that issue is fixed by including shiki-magic-move's stylesheet. This issue remains with the stylesheet included.
I noticed that the component was being re-rendered unnecessarily. Maybe an extra re-render was cancelling the animation abruptly.
Looking at the code, I noticed that the useMemo was updating a value it depended on. Recognizing that as a "loop-happy" pattern, I updated the memo's dependencies.
const result = React.useMemo(() => {
const res = syncTokenKeys(
previous,
steps[Math.min(step, steps.length - 1)],
options,
)
setPrevious(res.to)
return res
- }, [previous, steps, step, options])+ }, [steps, step, options])
Preview in the PR.
I don't understand the intention behind the hook, but this also allowed the code block to animate.
I am using the React renderer with precompiled tokens. The tokenization, serialization, and rendering all seem to work fine, but the transitions are all immediate, not animated.
video.mp4
The component looks like this:
compiledCode
is generated using this code:The text was updated successfully, but these errors were encountered: