728x90
반응형

리액트에서 디바이스 구분하기

export const isAndroid = () => {
    return /android/i.test(navigator.userAgent);
}

export const isiOS = () => {
    return /iphone|ipad/i.test(navigator.userAgent);
}

export const isiPhone = () => {
    return /iphone/i.test(navigator.userAgent);
}

export const isiPad = () => {
    return /ipad/i.test(navigator.userAgent);
}

export const isMobile = () => {
    return isAndroid() || isiOS();
}

export const isDetectMobile = () => {
    const minWidth = 600
    console.log(window.innerWidth);
    return window.innerWidth <= minWidth;
}
반응형
복사했습니다!