yuanyan/boron

Isomorphic apps cannot render this modal

Opened this issue · 6 comments

Please adjust this component to be able to render on the server for isomorphic (universal) apps.
This is becoming the standard now and it will be a shame not to use your component for lack of isomorphic support.
right now it throws an error because it has a dependency on document or window.
simply move the dependent code to componentDidMount...

+1

I was able to get it to run by monkey patching it which is not ideal...
I've download all the sources and modified modalFactory.js

var React = require('react');
var canUseDOM = !!(
  typeof window !== 'undefined' &&
  window.document &&
  window.document.createElement
);
var transitionEvents   = canUseDOM ? require('./transitionEvents')   : function() {};
var appendVendorPrefix = canUseDOM ? require('./appendVendorPrefix') : function() {};

then again in the actual Modal I was using... for example - OutlineModal.js

var React = require('react');
var modalFactory = require('../modalFactory');

var canUseDOM = !!(
  typeof window !== 'undefined' &&
  window.document &&
  window.document.createElement
);

var insertKeyframesRule = canUseDOM ? require('../insertKeyframesRule') : function() {} ;
var appendVendorPrefix  = canUseDOM ? require('../appendVendorPrefix')  : function() {} ;
n0isy commented

+1

I published a fixed version on npm as boron-ssr-fix.