Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wednesday-solutions/react-screentype-hook

React hook to get screen type(mobile, tablet, desktop, largeDesktop)
https://github.com/wednesday-solutions/react-screentype-hook

custom-breakpoints desktop mobile react react-hook screen-type tablet

Last synced: about 1 month ago
JSON representation

React hook to get screen type(mobile, tablet, desktop, largeDesktop)

Awesome Lists containing this project

README

        

# react-screentype-hook

> React hook to dynamically get current screen type (mobile, tablet, desktop, largeDesktop)

![](react-screentype-hook.svg)

## Install

```sh
// with npm
npm install react-screentype-hook

// with yarn
yarn add react-screentype-hook
```

## Sample Response

```javascript
const screenType = useScreenType();
console.log(screenType);
```

```
{
isLargeDesktop: false,
isDesktop: false,
isMobile: true,
isTablet: false
}
```

## How to use

### Without custom breakpoints

```javascript
import React from "react";
import useScreenType from "react-screentype-hook";

function App() {
const screenType = useScreenType();

return (




);
}

export default App;
```

### With custom breakpoints

```javascript
import React from "react";
import useScreenType from "react-screentype-hook";

function App() {
const screenType = useScreenType({
mobile: 400,
tablet: 800,
desktop: 1000,
largeDesktop: 1600,
});

return (




);
}

export default App;
```

## License

[MIT](LICENSE)