-
Notifications
You must be signed in to change notification settings - Fork 194
Closed
Description
Description
As of version 2.0.2, react-codemirror2 breaks server-side rendering, due to the import of codemirror requiring browser-level. A server-side render app needs extensive workaround (such as dynamic imports) or separate server/client components to use react-codemirror2 in an isomorphic app. See an example of an error below.
Desired Outcome
Enable react-codemirror2 to handle import of codemirror from a node context as is the case with server-side rendering.
Potential Fixes
- using a textarea if in an environment that does not support codemirror: server-side or mobile
- having a dummy codemirror implementation if no
window/navigatorglobal found.
Example Error:
> node dist/server/index.js
/home/dpula/projects/rookeries/node_modules/codemirror/lib/codemirror.js:18
var userAgent = navigator.userAgent;
^
ReferenceError: navigator is not defined
at /home/dpula/projects/rookeries/node_modules/codemirror/lib/codemirror.js:18:17
at userAgent (/home/dpula/projects/rookeries/node_modules/codemirror/lib/codemirror.js:11:82)
at Object.<anonymous> (/home/dpula/projects/rookeries/node_modules/codemirror/lib/codemirror.js:14:2)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
artkravchenko, scniro, gbhrdt, statico, timsuchanek and 2 more
Metadata
Metadata
Assignees
Labels
No labels