react-device-detect v2.0.0

v2.0.0
Added 6
  • Add new type isEmbedded that returns if device type is embedded
  • Add useDeviceData hook that returns all device data and accepts optional userAgent prop or uses window.navigator.userAgent
  • Add useDeviceSelectors hook that returns all available selectors and accepts optional userAgent prop or uses window.navigator.userAgent
  • Export BrowserTypes and OsTypes enums from the package
  • Add getSelectorsByUserAgent function that returns all selectors available for a given user agent
  • Add parseUserAgent function that returns all available data for a given user agent, useful in SSR
Changed 2
  • Package was completely rewritten
  • deviceDetect now accepts userAgent parameter and returns all available data for use in SSR
Removed 1
  • Views no longer accept viewClassName prop, use className instead

From react-device-detect

Package was completely rewritten. But there is not many breaking changes.

Breaking change:

Views doesn't accept viewClassName prop anymore, use className instead.

New type

New type isEmbedded was added, it returns if device type is embedded.

New hooks

useDeviceData and useDeviceSelectors hooks were introduces.

First returns all device data, second returns all available selectors. Both hooks accept either userAgent as prop, or take it from window.navigator.userAgent.

Enums

BrowserTypes and OsTypes are now exported from the package. They has not very big amount of entries for now, but they will be extended soon.

Utilities updates/additions

Added function getSelectorsByUserAgent which returns all selectors available for given user agent. User agent argument is mandatory.

Now deviceDetect accepts userAgent and returns all available data. Can be used in SSR.

Added function parseUserAgent which returns all available data for given user agent. Useful in SSR. User agent argument is mandatory.

View original

Upgraded? How did it go?

Discussion