duskload / react-device-detect

Detect device, and render view according to detected device type.
MIT License
2.81k stars 154 forks source link

Question about migrate to navigator.userAgentData issue show up in Chrome #214

Open LuanCGale opened 1 year ago

LuanCGale commented 1 year ago

Hi react-device-detect team, First of all, thank you for providing this useful framework to ease developer's daily work!

  1. Just notice in Chrome, it logs an issue:
    
    Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform
    A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. Starting in Chrome 101, the amount of information available in the User Agent string will be reduced.

To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData. Note that for performance reasons, only the first access to one of the properties is shown



2. Although after checking [can I use](https://caniuse.com/mdn-api_navigator_useragentdata) seems like not all browser supports this userAgentData object. I am just wondering what feature detection from this issue will be impacted.

3. [https://blog.chromium.org/2021/09/user-agent-reduction-origin-trial-and-dates.html](https://blog.chromium.org/2021/09/user-agent-reduction-origin-trial-and-dates.html)

Thanks again for the time and efforts you guys put in.