0.0.13 • Published 2 years ago

opgg-use-device-detector v0.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

opgg-use-device-detector

Check your device when you have anything to change on your PC or mobile.

❤️ it? ⭐️ it on GitHub

opgg-use-device-detector basically provides physical device data and logical device data.

  • Physical device: Device information that was accessed when the site was first accessed.
  • Logical device: Device information that changes internally when changing the current state to an arbitrary device.

Requirement

To use opgg-use-device-detector, you must use react@16.8.0 or greater which includes Hooks.

Installation

$ npm i opgg-use-device-detector

Usage

import useDeviceDetector from 'opgg-use-device-detector'

const deviceDetector = useDeviceDetector(initialState, deviceDetectorConfig)

Parameters

You pass useDeviceDetector an initialState and an optional deviceDetectorConfig object. The configuration object may contain the following keys.

KeyDescription
onChangeComming Soon!
storageKeyA string that will be used by the storageProvider to persist the logical device data. If you specify a value of null, nothing will be persisted. Default=logicalDeviceData.
storageProviderA storage provider. Default = localStorage. You will generally never need to change this value.

This version does not provide local storage usage and onChange functions.

2022.03.13
BugFix - Fix the bug where the physical device data is initialized.

2022.03.10
Update - Contributor setting.
Ongoing - Add window.navigator.userAgent parser.
Update - Remove the defense and lighten the project.

2022.03.07
Update - Remove device model and brand (Fixing the bug.)
Update - Add function version.1 (use local storage)

Return object

A deviceDetector object is returned with the following properties.

KeyDescription
physicalDeviceDevice information on the first visit.
logicalDeviceLogically changed device information.
isMobileCheck current state. (true = 'smartphone' / false = 'desktop')
toggle()A function that allows you to toggle 'smartphone' or 'desktop'.

License

MIT Licensed

Contributors

0.0.13

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago