reapp / reapp-ui

Amazing cross platform UI's with React and JavaScript
https://reapp.io
MIT License
257 stars 47 forks source link

reapp-ui suitable for server-side rendering? #92

Open jlipps opened 8 years ago

jlipps commented 8 years ago

I'm working on adding server-side rendering to my redux app. As part of that I need to import my routes which contains import references to my components which themselves import reapp-ui. Simply importing these things fails in Node with errors like the following:

if (!('ontouchstart' in window)) emulateTouch({
                        ^

ReferenceError: window is not defined
    at Object.<anonymous> (/Users/<...>/node_modules/reapp-ui/lib/desktopTouch.js:4:25)

AFAICT this means that reapp-ui is not suitable for server-side rendering. Am I missing something? Is there a way to somehow inject a mock window object?

Alternatively, is there a way to move this behavior into a function so it's not executed merely on import?