3 ms·
Anyone know how this works with React? The old version has a wrapper, but it's pretty crude.
by swalsh 6y ago
Anyone know how this works with React? The old version has a wrapper, but it's pretty crude.
- joelg 6y agoI've been using it with React for a couple months now. In my experience it's been a little awkward but overall fairly usable. It seems like it would be easy to write a wrapper for.
- pier25 6y agoI've never used CodeMirror, but I'm using ProseMirror by the same author and it relies a lot on having control of the DOM. I'm guessing the integration will be basically a wrapper component with a ref of a DOM node where CodeMirror will do its thing.
- dmitryminkovsky 6y ago> I'm guessing the integration will be basically a wrapper component with a ref of a DOM node where CodeMirror will do its thing. Pretty much. This is how my React ProseMirror integration works: https://github.com/dminkovsky/use-prosemirror/blob/main/src/ProseMirror.tsx https://github.com/dminkovsky/use-prosemirror/blob/main/src/.... Though there are some complexities. I believe CodeMirror would be the same.
- nicoburns 6y agoYou'd likely be better off using the library directly and writing your own wrapper. You could probably setup a basic one in 10 lines of code.
- jrv 6y agoI use it in React by pointing the setup code at a ref of the CodeMirror div container and then I store the CodeMirror View object in another separate ref of the component so I have access to it from other places. Slightly awkward, but seems to work fine.
- CoffeePython 6y agoNot sure on using CodeMirror but I’m using Ace on my vim learning tool because it has vim key bindings. It’s been a great tool! Would like to check out code mirror also though too and see if I like it better.
- gidan 6y agoTake a look at draftjs, it’s an alternative built by facebook (I’m not affiliated with Facebook in any way)