Skip to content

Commit d9861e6

Browse files
committed
Update README
1 parent 359a26e commit d9861e6

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
# React `ResizeObserver` Hook & Context · [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE-OF-CONDUCT.md)
1+
<p align="center">
2+
<img src="./React-Breakpoints.svg" alt="React Breakpoints logo" />
3+
</p>
4+
5+
<h1 align="center">React ResizeObserver Hook</h1>
6+
7+
<p align="center">
8+
<img alt="npm version" src="https://img.shields.io/npm/v/@envato/react-resize-observer-hook?style=for-the-badge" />
9+
<img alt="react version" src="https://img.shields.io/npm/dependency-version/@envato/react-resize-observer-hook/dev/react?style=for-the-badge">
10+
<img alt="license" src="https://img.shields.io/npm/l/@envato/react-resize-observer-hook?style=for-the-badge" />
11+
<a href="CODE-OF-CONDUCT.md"><img alt="contributor covenant v2.0 adopted" src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=for-the-badge" /></a>
12+
</p>
13+
14+
---
215

316
> Observe multiple React components with a single ResizeObserver.
417
@@ -9,17 +22,21 @@ This package provides you with:
922

1023
This allows you to know the size of each observed element.
1124

12-
# Developer status
25+
# 🚧 Developer status
1326

1427
While this package has seen little action "in the wild", it has first been developed and groomed elsewhere. As such, I don't expect a lot of changes conceptually. However, the API of this hook is not finalised and may change at any given time.
1528

16-
# Usage
29+
# 📚 Docs
30+
31+
This package was developed **and documented** as part of the [`@envato/react-breakpoints`](https://github.com/envato/react-breakpoints) package. It's separated into its own package because I believe it can be used separately if you don't need all the abstractions that React Breakpoints gives you. Please refer to the [React Breakpoints API Docs](https://github.com/envato/react-breakpoints/docs/api.md) for more details about `<Provider>` and `useResizeObserver()`.
32+
33+
# ⚡️ Quick start
1734

1835
```shell
1936
npm install @envato/react-resize-observer-hook
2037
```
2138

22-
## Set up the Provider
39+
## Set up the provider
2340

2441
```javascript
2542
import { Provider as ResizeObserverProvider } from '@envato/react-resize-observer-hook';
@@ -31,18 +48,7 @@ const App = () => (
3148
);
3249
```
3350

34-
⚠️ **Caution**: `Provider` instantiates a `window.ResizeObserver` by default. [`window.ResizeObserver` currently has weak browser support](https://caniuse.com/#feat=mdn-api_resizeobserver_resizeobserver). You may pass a `ResizeObserver` constructor to `Provider` to use instead of `window.ResizeObserver`. I recommend [ponyfilling](https://github.com/sindresorhus/ponyfill) using [`@juggle/resize-observer`](https://github.com/juggle/resize-observer). You can also [monkey patch](https://en.wikipedia.org/wiki/Monkey_patch) `window.ResizeObserver` and use `Provider` without the `ponyfill` prop.
35-
36-
```javascript
37-
import { Provider as ResizeObserverProvider } from '@envato/react-resize-observer-hook';
38-
import ResizeObserver from '@juggle/resize-observer'; // Ponyfill
39-
40-
const App = () => (
41-
<ResizeObserverProvider ponyfill={ResizeObserver}>
42-
...
43-
</ResizeObserverProvider>
44-
);
45-
```
51+
⚠️ **Caution** — You may need to pass some props to `<Provider>` to increase browser support. Please refer to the [React Breakpoints API Docs](https://github.com/envato/react-breakpoints/docs/api.md#provider).
4652

4753
## Observe an element
4854

React-Breakpoints.svg

Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)