Closed joelove closed 7 years ago
Let’s try it out! Thanks!
This PR broke the build when run on the server. navigator
is not defined. :(
@HugoGiraudel : You can add a hack to mock navigator
on the server side to get around this. For Koa, it would be:
global.navigator = { userAgent : ctx.request.headers['user-agent'] };
Put that in the route handler that does your SSR (probably your *
handler)
This is a fix for this issue: https://github.com/insin/react-maskedinput/issues/75
In the end, I had to go with user agent sniffing even though it's a really ugly solution ~and will cause a breakage when Microsoft finally get their **** together~. Anything else was causing unexpected behaviour in other browsers. But it will solve the problem for 99% of users for now.
I did attempt to use feature detection, but it turns out detecting built-in browser events is a really complicated process and I really didn't want to introduce Modernizr just for this.
I also wasn't able to write unit tests for this because I couldn't find a way to make React DOM spoof the user agent and I couldn't find any documentation on how to manually configure PhantomJS on the fly in this test suite configuration.
Tested in: