Server rendering: "document is not defined" on refresh (reconcile transaction problem?)
I'm facing a strange issue...
I have a Rails app configured to use react-rails and use the prerendering feature. When I first load my home page, it renders well without any errors. I can confirm it is prerendered on the server as the received HTML contains the complete markup.
However, when I refresh the page (simple Cmd+R), I get the following error:
Encountered error "ReferenceError: document is not defined" when prerendering AppRouter with { ... state object ... }
There's no trace of a document call/access in my javascript code.
This is how AppRouter is rendered in my view:
<%= react_component('AppRouter', { initialAppState: @application_state }, { prerender: true }) %>
Killing and restarting the dev server "fixes" the problem until the next refresh is done. Changing some code in the AppRouter component will usually have it working again for the next refresh...
So this does look like a cache issue, but I can't figure out what exactly is going on?
Check React issue facebook/react#3620, should be fixed in React 0.14.