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
importReact,{useState,useEffect}from"react";import{createHighlighter,typeHighlighterCore}from"shiki";import{ShikiMagicMove}from"shiki-magic-move/react";constCodePage: React.FC=()=>{const[code,setCode]=useState(`function greet() { console.log('Hello, World!'); } greet();`);const[highlighter,setHighlighter]=useState<HighlighterCore>();useEffect(()=>{asyncfunctioninitializeHighlighter(){consthighlighter=awaitcreateHighlighter({themes: ["nord"],langs: ["javascript","typescript"],});setHighlighter(highlighter);}initializeHighlighter();},[]);functionanimate(){setCode(`const name = 'Alice'; function greet() { console.log('Hello, ' + name + '!'); } greet();`);}return(<div>{highlighter &&(<><ShikiMagicMovelang="ts"theme="nord"highlighter={highlighter}code={code}options={{duration: 750,stagger: 7,lineNumbers: true}}/><buttononClick={animate}>Animate</button></>)}</div>);};exportdefaultCodePage;
Probably I am missing something because I just copied the example from readme.
It is not as smooth as it is seen at https://shiki-magic-move.netlify.app/
I could not make the react animation work
Probably I am missing something because I just copied the example from readme.
It is not as smooth as it is seen at https://shiki-magic-move.netlify.app/
For quickly trying you can use this codesandbox: https://codesandbox.io/p/sandbox/yk9dxt?file=%2Fsrc%2FApp.tsx%3A29%2C22
The text was updated successfully, but these errors were encountered: