-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
In order to reduce bundle size of this project which is potentially causing inflated bundle sizes on its dependents, I suggest removal of some packages from dependencies and use native solutions instead:
- Replace react-device-detect with a custom hook. Example:
import React from "react"
export default function useDeviceDetect() {
const [isMobile, setMobile] = React.useState(false)
const [isDesktop, setDesktop] = React.useState(false)
const [isAndroid, setAndroid] = React.useState(false)
const [isIOS, setIOS] = React.useState(false)
React.useEffect(() => {
const userAgent =
typeof window.navigator === "undefined" ? "" : navigator.userAgent
const mobile = Boolean(
userAgent.match(
/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i
)
)
const android = Boolean(userAgent.match(/Android/i))
const ios = Boolean(userAgent.match(/iPhone|iPad|iPod/i))
setMobile(mobile)
setDesktop(!mobile)
setAndroid(android)
setIOS(ios)
}, [])
return { isMobile, isDesktop, isAndroid, isIOS }
}
- Replace axios with native fetch function
- Replace react-modal with a native React modal solution
Metadata
Metadata
Assignees
Labels
No labels