Member-only story

Top React Hooks — Async and Window

John Au-Yeung
3 min readOct 7, 2020

--

Photo by Dan Gold on Unsplash

Hooks contains our logic code in our React app.

We can create our own hooks and use hooks provided by other people.

In this article, we’ll look at some useful React hooks.

React Recipes

React Recipes comes with many hooks that we can use to do various things.

The useWindowSize hook lets watch the size of the window as it changes.

For instance, we can write:

import React from "react";
import { useWindowSize } from "react-recipes";
export default function App() {
const { width, height } = useWindowSize();
return (
<div>
{width}x{height}
</div>
);
}

We call the useWindowSize hook to return the width and height properties.

They’re the width and height of the window.

We can also pass in the initial width and height, which are useful for server-side rendered apps.

It comes with many other useful hooks to make our lives easier.

React Request Hook

The React Request Hook library lets us make requests with ease.

--

--

No responses yet