REACT detect browser from useragent react - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution

detect browser from useragent react


 346

Show ResultREACT


3

<!DOCTYPE html>
<html>
<head>
<script src="https://fb.me/react-0.14.3.min.js"></script>
<script src="https://fb.me/react-dom-0.14.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
</head>
<body>
<script type="text/babel">

class App extends React.Component {
constructor() {
super();

this.state = {
data: []
}

this.setStateHandler = this.setStateHandler.bind(this);
};

setStateHandler() {

var msg;

if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true ))
{
msg = "IE";
this.setState({data: msg})
}
else if(navigator.appVersion.indexOf('Edge') > -1)
{
msg = "Edge";
this.setState({data: msg})
}
else if(navigator.userAgent.toLowerCase().indexOf("op") > -1)
{
msg = "Opera";
this.setState({data: msg});
}
else if(navigator.userAgent.indexOf("Chrome") != -1)
{
msg = "Chrome";
this.setState({data: msg})
}
else if(navigator.userAgent.indexOf("Firefox") != -1 )
{
msg = "Firefox";
this.setState({data: msg})
}
else if(navigator.userAgent.indexOf("Safari") != -1)
{
msg = "Safari";
this.setState({data: msg})
}
else
{
msg = "Unknown";
this.setState({data: msg})
}

};

render() {
return (
<div>
<button onClick = {this.setStateHandler}>Click</button>
<h2>{this.state.data}</h2>
</div>
);
}
}

ReactDOM.render(
<App/>,
document.getElementById('my-div')
);

</script>

<div id="globe">
<div id="my-div"></div>
</div>

</body>
</html>


By     Created   
The power of the user (%)
11%



The most helpful REACT solutions

How to get client ip address using react ?How to get client ip address using react ?REACT

Click to see more ...

  7.2K     419

how to get the type of a device using react ?how to get the type of a device using react ?REACT

Click to see more ...

  1.8K     213

create digital clock reactcreate digital clock reactREACT

Click to see more ...

  1.1K     136

country dropdown using reactcountry dropdown using reactREACT

Click to see more ...

  916     127

How to get latitude and longitude using react/javascript ?How to get latitude and longitude using react/javascript ?REACT

Click to see more ...

  762     108

get client country reactget client country reactREACT

Click to see more ...

  496     82

get ip address reactget ip address reactREACT

Click to see more ...

  540     80

time ago reacttime ago reactREACT

Click to see more ...

  378     74

detect mobile device reactdetect mobile device reactREACT

Click to see more ...

  360     58

detect browser reactdetect browser reactREACT

Click to see more ...

  361     52