Is there any way to detect IE browser with React and either redirect to a page or give any helpful message. I found something in JavaScript, but not sure how would I use it with React+TypeScript.
var isEdge = !isIE && !!window.StyleMedia;
Is there any way to detect IE browser with React and either redirect to a page or give any helpful message. I found something in JavaScript, but not sure how would I use it with React+TypeScript.
var isEdge = !isIE && !!window.StyleMedia;
Try:
etc.
Each browser has a distinct user agent you can check.
These can be faked by the client of course, but in my opinion, are a more reliable long term solution.
You can write test for IE like this.
This is the service I always use when doing JS/Browser based browser-detection: http://is.js.org/
You are on the right track you can use these to conditionally render jsx or help with routing...
I have used the following with great success.
Originally from - How to detect Safari, Chrome, IE, Firefox and Opera browser?
Please be aware they each stand a chance to deprecated due to browser changes.
I use them in React like this:
Then by calling {this.Content()} in my main component to render the different browser specific elements.
Pseudo code might look something like this... (untested):
This is all information you can get from your the browser of you client (using react):
The browser is
browserName
This almost broke me, but I found something which seems pretty simple and straight forward, use the vendor name. ie. Google, Apple etc.
navigator.vendor.includes('Apple')
I hope this helps someone out there.