react-device-detect
react-device-detect copied to clipboard
BrowserView, MobileView, TabletView shows on iPad at the same time
- Bug description BrowserView, MobileView, TabletView shows on iPad at the same time
- Steps to reproduce Add BrowserView, MobileView, TabletView into react component, start iPad simulator on macOS, open page in safari
- Device user-agent
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15"
I used this user-agent in desktop chrome and the issue is not appearing. - Device/Browser type/name Safari on iPad simulator, iPad (8th generation), and all pro versions with ipadOS 14
- Share code for a better understanding (for example, here https://codesandbox.io/s/new) https://codesandbox.io/s/priceless-williamson-r8xug?file=/src/App.js
- Any additional info
version of lib: v1.14.0
Glad I'm not the only one. Is there any workaround that you know of at this moment @h3xsoul ?
I know this problem doesn't appear when using chrome on the ipad, but I need to handle the safari edge case as well.
@matthew9510 As you can see from the screenshot isTablet
= true
for tablets and false
for mobile and desktops. So I used {!isTablet && <BrowserView/> }
in this case it will show proper view on each platform
@h3xsoul right on. Thanks
I fixed it by making my own BrowserView which I import instead of the original one
import React from 'react';
import {CustomView, isBrowser, isTablet} from "react-device-detect";
export default function BrowserView ({children, ...props}) {
return (
<CustomView condition={isBrowser && !isTablet} {...props}>
{children}
</CustomView>
)
}