ufocoder / redux-universal-boilerplate

Boilerplate for react universal (isomorphic) application based on flux architecture (redux implementation)
MIT License
72 stars 19 forks source link

server hangs on window object #9

Closed Jinnified closed 8 years ago

Jinnified commented 8 years ago

Hi

It seems that in any react component, whenever you try to access 'window', even in console log, then you try to refresh, the server will starts hanging, looks like this window obj been overwritten by the backend?

Jinnified commented 8 years ago

looks like you can not access any build in js object such as window or document in react's render methods

ufocoder commented 8 years ago

I can't understand the problem totally, did you mean how you should work with window object in boilerplate?

There're only two places in boilerplate that modify window object

  1. Set initial state on server side, URL: https://github.com/ufocoder/redux-universal-boilerplate/blob/master/src/server/containers/Html/index.js#L38
  2. Delete applied initial state, URL: https://github.com/ufocoder/redux-universal-boilerplate/blob/master/src/client/index.js#L40

Also remember that this boilerplate isomorphic (universal) and if you want to work with browser objects such as navigator, window, and etc. you should work with them in componentDidMount component method, check react documentation please

Anyway write here if your issue was resolved by my comment or not? If not please give me more details

Jinnified commented 8 years ago

yea, you were right, because of it's universal, so browser object can only be accessed post render stage, etc, didMount, didUpdate, etc

but dont know if it can be made not hanging when those objects are been accessed, say, in render() or componentWillMount()

ufocoder commented 8 years ago

@Jinnified I will add a note in README.md perhaps for this moment