REACT get type device react - Net-Raft.com

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




Just a Web Code Solution

how to get the type of a device using react ?


 1594

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 (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
b = "mobile device";
}
else {
b = "desktop";
}

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

</script>

</body>
</html>


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

REACT


2

// at first you install npm install react-useragent

import React from 'react';
import withUserAgent from 'react-useragent';

class App extends React.Component {
render() {
return (
<div>
{this.props.ua.mobile ? (
"mobile"
) : (
"something else"
)}
</div>
);
}
}

export default withUserAgent(App);


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

Show ResultREACT


1

<!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 (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {

device = "mobile device";

}

else {

device = "desktop";

}
</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 (%)
43%



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

  6.4K     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.6K     203

country dropdown using reactcountry dropdown using reactREACT

Click to see more ...

  895     127

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

Click to see more ...

  679     104

get client country reactget client country reactREACT

Click to see more ...

  480     82

get ip address reactget ip address reactREACT

Click to see more ...

  496     81

time ago reacttime ago reactREACT

Click to see more ...

  355     74

detect mobile device reactdetect mobile device reactREACT

Click to see more ...

  346     58

detect browser reactdetect browser reactREACT

Click to see more ...

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

  282     51