maslianok / react-resize-detector

A Cross-Browser, Event-based, Element Resize Detection for React
http://maslianok.github.io/react-resize-detector/
MIT License
1.25k stars 91 forks source link

Allow React 18 as peerDependency #206

Closed snelsi closed 2 years ago

snelsi commented 2 years ago

React 18 is backward compatible, please, allow React version ^18.0 as peerDependency in package.json https://reactjs.org/blog/2022/03/29/react-v18.html

theniceboy commented 2 years ago

https://github.com/maslianok/react-resize-detector/blob/353457dacdd132073276d597c83d12341a6cdeaf/README.md?plain=1#L1

Support React 18 like it's 2022! 😄

Btw thank you for this package! This is awesome!

michaelbull commented 2 years ago

React 18 is backward compatible

It isn't. Issue #208 highlights a major regression that needs addressing first, the solution for which is in PR #209.

It won't work out-of-the-box in React 18 until this is addressed.

AntonOfTheWoods commented 2 years ago

Handle element resizes like it's 2022!... Handle element resizes like it's H2 2022!?

maslianok commented 2 years ago

Thank you, guys. We have a complex situation here in Ukraine, so I'm a bit off from my OS projects. Hope you understand and continue using this library.

maslianok commented 2 years ago

Published in v7.0.1

maslianok commented 2 years ago

React 18 is backward compatible

It isn't. Issue #208 highlights a major regression that needs addressing first, the solution for which is in PR #209.

It won't work out-of-the-box in React 18 until this is addressed.

209 is merged too. published v7.0.2

ddkang commented 2 years ago

Thank you so much! Stay safe

k-funk commented 6 months ago

@maslianok

is it possible to get the change

  "peerDependencies": {
    "react": "^16.0.0 || ^17.0.0 || ^18.0.0",
    "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
  },

in v6.x as well? my team's project isn't yet ready to drop 2020 browser support.

snelsi commented 6 months ago

@k-funk There's no need to stay on v6. You can upgrade to the latest version of react-resize-detector and add a polyfill for ResizeObserver yourself.

v6 uses resize-observer-polyfill library. Here's how you can achieve the same behavior:

1) Install the polyfill:

npm install resize-observer-polyfill --save-dev

2) Import the .global version of the polyfill at the top of your boot file:

import 'resize-observer-polyfill/dist/ResizeObserver.global'

3) Alternatively, you can import the ponyfill and attach it to the global window object at the top of your boot file like this:

import ResizeObserver from "resize-observer-polyfill"

window.ResizeObserver = ResizeObserver;
k-funk commented 6 months ago

@k-funk There's no need to stay on v6. You can upgrade to the latest version of react-resize-detector and add a polyfill for ResizeObserver yourself.

v6 uses resize-observer-polyfill library. Here's how you can achieve the same behavior:

  1. Install the polyfill:
npm install resize-observer-polyfill --save-dev
  1. Import the .global version of the polyfill at the top of your boot file:
import 'resize-observer-polyfill/dist/ResizeObserver.global'
  1. Alternatively, you can import the ponyfill and attach it to the global window object at the top of your boot file like this:
import ResizeObserver from "resize-observer-polyfill"

window.ResizeObserver = ResizeObserver;

Fantastic, thank you!

Might be worth adding this to the README for others to find.