JedWatson / react-input-autosize

Auto-resizing input field for React
https://jedwatson.github.io/react-input-autosize
MIT License
769 stars 178 forks source link

Window reference in AutosizeInput causes fail in SSR #117

Closed talbenmoshe closed 6 years ago

talbenmoshe commented 6 years ago

Hi, A recent change causes a build fail when using this component in server-side-rendering.

ReferenceError: window is not defined

This error comes from this line: https://github.com/JedWatson/react-input-autosize/blob/master/lib/AutosizeInput.js#L57

JedWatson commented 6 years ago

This is like playing whack-a-mole...

Fixed thanks to @wmertens, published in v2.1.2

BowlingX commented 6 years ago

This still fails in some cases the SSR defines window, it's safer to additionally check the document, see here: https://stackoverflow.com/questions/13644303/how-to-check-if-js-code-is-running-on-node-server-or-on-the-client/13644360#13644360