Closed softshipper closed 3 years ago
Oh, it looks like we should update the documentation to match what we use in the implementation:
Does the alternative work? Do you want to update the documentation?
diff --git a/docs/src/modules/components/AppNavDrawer.js b/docs/src/modules/components/AppNavDrawer.js
index 9d1cbc746e..5b006b1e32 100644
--- a/docs/src/modules/components/AppNavDrawer.js
+++ b/docs/src/modules/components/AppNavDrawer.js
@@ -141,7 +141,7 @@ function reduceChildRoutes(context) {
// iOS is hosted on high-end devices. We can enable the backdrop transition without
// dropping frames. The performance will be good enough.
// So: <SwipeableDrawer disableBackdropTransition={false} />
-const iOS = process.browser && /iPad|iPhone|iPod/.test(navigator.userAgent);
+const iOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent);
function AppNavDrawer(props) {
const { classes, className, disablePermanent, mobileOpen, onClose, onOpen } = props;
diff --git a/docs/src/pages/components/drawers/drawers.md b/docs/src/pages/components/drawers/drawers.md
index 5fa5fd5f79..0275552bf0 100644
--- a/docs/src/pages/components/drawers/drawers.md
+++ b/docs/src/pages/components/drawers/drawers.md
@@ -43,7 +43,7 @@ The following properties are used in this documentation website for optimal usab
with the discovery feature, so discovery has to be disabled.
```jsx
-const iOS = process.browser && /iPad|iPhone|iPod/.test(navigator.userAgent);
+const iOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent);
<SwipeableDrawer disableBackdropTransition={!iOS} disableDiscovery={iOS} />;
It works like a charm. I would love to update the documentation. However, I have a question regarding to:
const iOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent);
Does it work also for JS? Or do I have to differentiate in the documentation?
Thanks a lot
It works like a charm. I would love to update the documentation.
Feel free to send a pull request then :)
Does it work also for JS?
What do you mean?
I am using typescript to build my react app. What I mean is, if the code
const iOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent)
also works for react JS version?
Yes
Thanks.
Hi all
I am trying to implement Swipeable Drawer from Material-UI. For performance reason, I would like to implement
as recommended on the page.
I have created a component as follows:
and the compiler complains:
Material-ui version v4.11.2.
Thanks