REACT detect browser 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 react


 304

REACT


3

import React from 'react';

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>
);
}
}

export default App;


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

Show ResultREACT


2

<!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>
</head>
<body>

<script type="text/javascript">

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

</script>

<script type="text/javascript">

var div = React.DOM.div

var HelloWorldComponent = (
div(null,'' + device + '')
)

ReactDOM.render(HelloWorldComponent, document.getElementsByTagName('body')[0]);

</script>

</body>
</html>


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

Show ResultREACT


2

<!DOCTYPE html>
<html>
<head>
</head>
<body>

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

<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>
<script type="text/babel">

var MyReact = React.createClass({
render: function() {
return (
<p>{this.props.a}</p>
);
}
});

var a;
var b;
if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true ))
{
b = "IE";
}
else if(navigator.appVersion.indexOf('Edge') > -1)
{
b = "Edge";
}
else if(navigator.userAgent.toLowerCase().indexOf("op") > -1)
{
b = "Opera";
}
else if(navigator.userAgent.indexOf("Chrome") != -1)
{
b = "Chrome";
}
else if(navigator.userAgent.indexOf("Firefox") != -1 )
{
b = "Firefox";
}
else if(navigator.userAgent.indexOf("Safari") != -1)
{
b = "Safari";
}
else
{
b = "unknow";
}

ReactDOM.render(
<MyReact a={b}/>,
document.getElementById('my-div')
);

</script>

</body>
</html>


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

REACT


1

// at first you install npm install --save react-browser-detection

import React, { Component } from 'react';
import BrowserDetection from 'react-browser-detection';

const browserHandler = {
default: (browser) => <div>{browser}</div>
};

export default class App extends Component {
render() {
return (
<BrowserDetection>
{ browserHandler }
</BrowserDetection>
);
}
}


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



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 ...

  4.9K     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.5K     203

country dropdown using reactcountry dropdown using reactREACT

Click to see more ...

  842     127

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

Click to see more ...

  629     104

get ip address reactget ip address reactREACT

Click to see more ...

  403     81

time ago reacttime ago reactREACT

Click to see more ...

  297     73

detect mobile device reactdetect mobile device reactREACT

Click to see more ...

  269     58

get client country reactget client country reactREACT

Click to see more ...

  332     53

detect browser reactdetect browser reactREACT

Click to see more ...

  304     52

how to detect a mobile device not tablet using react ?how to detect a mobile device not tablet using react ?REACT

Click to see more ...

  253     51