scniro / react-codemirror2

Codemirror integrated components for React
MIT License
1.65k stars 192 forks source link

ReferenceError: navigator is not defined #11

Closed nakkeeran closed 6 years ago

nakkeeran commented 6 years ago

@scniro Facing same issue in react-codemirror2 https://github.com/JedWatson/react-codemirror/issues/77

Issue addressed in this PR https://github.com/JedWatson/react-codemirror/pull/31

Can you please include in react-codemirror2.

Thanks

scniro commented 6 years ago

Interesting. Did you notice the bit one commented on regarding modes?

For what it's worth, require('react-codemirror') itself does not produce the error. Just including the modes does. So you could make that first require unconditional and render unconditionally as well.

Since this plugin does not include any modes, perhaps the check can be done on your end since it'll still be an issue even if I did implement this. I'd assume the following (example) could work for you...

if (typeof navigator !== 'undefined') {
  require('codemirror/mode/xml/xml');
  require('codemirror/mode/javascript/javascript');
  // [...]
}
nakkeeran commented 6 years ago

Thanks @scniro 👍🏼