https://github.com/heineiuo/react-platform
<Platform> for browser. Move to ——→
https://github.com/heineiuo/react-platform
platform react ua-parser-js
Last synced: 3 months ago
JSON representation
<Platform> for browser. Move to ——→
- Host: GitHub
- URL: https://github.com/heineiuo/react-platform
- Owner: heineiuo
- Created: 2017-05-19T02:23:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-14T13:46:13.000Z (about 9 years ago)
- Last Synced: 2025-10-04T09:48:59.555Z (10 months ago)
- Topics: platform, react, ua-parser-js
- Language: JavaScript
- Homepage: https://github.com/heineiuo/react-web/tree/master/packages/platform
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @react-shared/platform
## Install
```bash
yarn add @react-shared/platform # or npm install @react-shared/platform
```
## Usage
### method
```javascript
import Platform from '@react-shared/platform'
Platform.OS // OS name, Mac OS
Platform.OSVersion // OS version, 10.11
Platform.Browser // Browser name, Chrome
Platform.BrowserVersion // Browser Version
Platform.Engine // browser engine name
// and ...
Platform.CPU
Platform.DeviceType
Platform.DeviceModel
Platform.DeviceVendor
Platform.UA
```
### component
```javascript
import React, {Component} from 'react'
import Platform from '@react-shared/platform'
class App extends Component {
render() {
return (
Only Mac OS computer will see this text.
)
}
}
/**
* use function children
* *important* in this way, prop 'rules' will not work
*/
class App2 extends Component {
render() {
return (
{props => {
return (
OS: {props.OS},
OSVersion: {props.OSVersion},
Browser: {props.Browser},
BrowserVersion: {props.BrowserVersion},
DeviceType: {props.DeviceType},
DeviceModel: {props.DeviceModel},
DeviceVendor: {props.DeviceVendor},
Engine: {props.Engine},
EngineVersion: {props.EngineVersion},
CPU: {props.CPU},
UA: {props.UA},
)
}}
)
}
}
```
#### props
* *rules*
* *className* only work when children is string or array
* *style* only work when children is string or array
## License
MIT