uiwjs / react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
https://uiwjs.github.io/react-codemirror/
MIT License
1.62k stars 128 forks source link

Display skeleton before render #674

Open haaarshsingh opened 2 months ago

haaarshsingh commented 2 months ago

I'm having a bunch of layout shift because this editor renders in after the rest of my components. How can I know if it has loaded or not so I can display a skeleton or something?

jaywcjlove commented 2 months ago

@harshhhdev Do you need an effect like this? I think this requires implementation on your part.

<Skeleton loading={loading}>
     <CodeMirror value={goLang} height="200px" extensions={[StreamLanguage.define(go)]} />
</Skeleton>
haaarshsingh commented 2 months ago

@jaywcjlove yessir, exactly like that. How should I go about making the loading implementation myself though? 🤔

jaywcjlove commented 1 month ago

Do I need to add a componentDidMount prop?