microsoft / fluentui

Fluent UI web represents a collection of utilities, React components, and web components for building web applications.
https://react.fluentui.dev
Other
18.52k stars 2.73k forks source link

[Bug]: Incompatible with React 19 - useDisposable #31471

Open daniharo opened 5 months ago

daniharo commented 5 months ago

Library

React Components / v9 (@fluentui/react-components)

System Info

System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M1
  Memory: 60.69 MB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Browsers:
  Safari: 17.4.1
  Chrome: 125.0.6422.76

NPM packages:
@fluentui/react-components: 9.53.0
react: 19.0.0@rc
react-dom: 19.0.0@rc

Are you reporting Accessibility issue?

no

Reproduction

https://codesandbox.io/p/sandbox/fluentui-react-components-with-react-19-g4g5pw?file=%2Fsrc%2FApp.tsx

Bug Description

@fluentui/react-portal depends on use-disposable, which is incompatible with React 19: https://github.com/microsoft/use-disposable/issues/31 https://github.com/microsoft/fluentui/blob/babf7b45951d2e27f9724f3bbdd3dd77aee2c488/packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts#L38-L46

Any component which uses Portal (such as Tooltip or Dialog) throws this error: "TypeError: Cannot read properties of undefined (reading 'ReactCurrentOwner')", as you can see in the repro.

React 19 stable is meant to be released next week.

Logs

TypeError
Cannot read properties of undefined (reading 'ReactCurrentOwner')
getCurrentOwner
/node_modules/use-disposable/lib/index.js:28:86
useIsStrictMode
/node_modules/use-disposable/lib/index.js:42:24
useDisposable
/node_modules/use-disposable/lib/index.js:78:24
    at usePortalMountNode (/node_modules/
fluentui/react-portal/lib-commonjs/components/Portal/usePortalMountNode.js:27:54
    at usePortal_unstable (/node_modules/
fluentui/react-portal/lib-commonjs/components/Portal/usePortal.js:19:72
    at Portal (/node_modules/
fluentui/react-portal/lib-commonjs/components/Portal/Portal.js:16:53

Requested priority

High

Products/sites affected

No response

Are you willing to submit a PR to fix?

no

Validations

ValentinaKozlova commented 5 months ago

@daniharo, work on this issue is already in progress