Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
daniharo opened this issue May 24, 2024 · 2 comments
Closed
2 tasks done

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

daniharo opened this issue May 24, 2024 · 2 comments

Comments

@daniharo
Copy link
Contributor

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: microsoft/use-disposable#31

const element = useDisposable(() => {
if (targetNode === undefined || options.disabled) {
return [null, () => null];
}
const newElement = targetNode.ownerDocument.createElement('div');
targetNode.appendChild(newElement);
return [newElement, () => newElement.remove()];
}, [targetNode]);

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

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@ValentinaKozlova
Copy link
Contributor

@daniharo, work on this issue is already in progress

@miroslavstastny miroslavstastny changed the title [Bug]: Incompatible with React 19 [Bug]: Incompatible with React 19 - useDisposable May 27, 2024
@layershifter
Copy link
Member

Duplicate of #31429

@layershifter layershifter marked this as a duplicate of #31429 Nov 18, 2024
@layershifter layershifter closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants