1.3.1 • Published 1 year ago

react_use_is_mobile v1.3.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

useIsMobile

A simple React hook to detect if the current screen size is considered mobile.

Installation

You can install useIsMobile using npm:

npm install react_use_is_mobile

Usage

import React from "react";
import useIsMobile from "react_use_is_mobile";

function MyComponent() {
  const isMobile = useIsMobile();

  return <div>{isMobile ? <p>Mobile View</p> : <p>Desktop View</p>}</div>;
}

How it works

The useIsMobile hook utilizes the window.innerWidth property to determine if the screen size is less than or equal to 768 pixels, considering it as a mobile view.

It also includes an event listener for the resize event to update the isMobile state dynamically when the screen size changes.

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago