material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[TextField] `dispatcher.useId` is not a function in React 18

Open zl-david opened this issue 3 years ago • 10 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Current behavior 😯

When rendering the <TextField /> component in a React 18 project (e.g. in BlitzJS), following error is shown:

TypeError
dispatcher.useId is not a function

useId
[https://yeev72.csb.app/node_modules/react/cjs/react.development.js:1697:21]()
useId@https://yeev72.csb.app/node_modules/
[mui/utils/esm/useId.js:22:21]()
TextField@https://yeev72.csb.app/node_modules/
[mui/material/TextField/TextField.js:92:50]()
...

Expected behavior 🤔

The Textfield component renders without errors

Steps to reproduce 🕹

Example in this codesandbox

Context 🔦

No response

Your environment 🌎

`npx @mui/envinfo`

  System:
    OS: macOS 12.2.1
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 19.84 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.1/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Managers:
    Homebrew: 3.3.11 - /usr/local/bin/brew
    Maven: 3.5.4 - /usr/local/bin/mvn
    RubyGems: 3.0.3.1 - /usr/bin/gem
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 4.2.1 - /usr/bin/gcc
    Git: 2.30.1 - /usr/bin/git
    Clang: 12.0.5 - /usr/bin/clang
  Servers:
    Apache: 2.4.51 - /usr/sbin/apachectl
  Virtualization:
    Docker: 20.10.12 - /usr/local/bin/docker
    Parallels: 16.0.1 - /usr/local/bin/prlctl
    VirtualBox: 5.2.22 - /usr/local/bin/vboxmanage
  IDEs:
    IntelliJ: 2021.2.3
    Nano: 2.0.6 - /usr/bin/nano
    Sublime Text: Build 3211
    Vim: 8.2 - /usr/bin/vim
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Go: 1.12.5 - /usr/local/bin/go
    Java: javac 16 - /Users/david/.sdkman/candidates/java/current/bin/javac
    Perl: 5.30.3 - /usr/bin/perl
    Python: 2.7.15 - /usr/local/bin/python
    Python3: 3.8.2 - /usr/bin/python3
    Ruby: 2.6.8 - /usr/bin/ruby
  Databases:
    SQLite: 3.36.0 - /usr/bin/sqlite3
  Browsers:
    Chrome: 98.0.4758.102
    Edge: 98.0.1108.56
    Firefox: 97.0.1
    Safari: 15.3

Tested in Chrome and Firefox

zl-david avatar Feb 24 '22 07:02 zl-david

Hi, this is an issue that I had as well. I know that it isn't a solution, but my Blitz.js setup worked when I downgraded to react and react-dom 17. Whatever the issue is, it has something to do with 18.

benbourgeois-92 avatar Feb 25 '22 20:02 benbourgeois-92

Using "react": "18.0.0-alpha-5ca4b0433-20211020" and "react-dom": "18.0.0-alpha-5ca4b0433-20211020" also works for me.

tom-richter avatar Mar 08 '22 16:03 tom-richter

@tom-richter Thanks, using 18.0.0-alpha-5ca4b0433-20211020 works for me as well! (I couldn't downgrade to 17 because Suspense is not supported)

zl-david avatar Mar 08 '22 18:03 zl-david

I switched to "react": "18.0.0-beta-24dd07bd2-20211208" and "18.0.0-beta-24dd07bd2-20211208" - Works as well :)

aklassen avatar Mar 18 '22 18:03 aklassen

still an issue with react 18. is there an update?

cindyloo avatar Jun 16 '22 14:06 cindyloo

Closing this issue as it works with the latest React v18.2.0

ZeeshanTamboli avatar Jul 18 '22 08:07 ZeeshanTamboli

Closing this issue as it works with the latest React v18.2.0

I have this same issue on "react": "^18.2.0".

error - TypeError: dispatcher.useId is not a function

Anyone knows what it is?

PrimozRome avatar Aug 04 '22 07:08 PrimozRome

@PrimozRome Please provide a CodeSandbox reproducing the issue.

ZeeshanTamboli avatar Aug 04 '22 07:08 ZeeshanTamboli

I have the same error when try to use the Modal component from 'antd' library.

"react": "^18.2.0", "react-dom": "18.2.0",

olegzaitsevway avatar Aug 08 '22 09:08 olegzaitsevway

@PrimozRome Please provide a CodeSandbox reproducing the issue.

I have managed to solve the issue. I only upgraded react but not react-dom. After that, the error was gone!

PrimozRome avatar Aug 08 '22 10:08 PrimozRome

Issue is still peristant when testing mui5 components with enzyme in react18.2 and react-dom 18.2

CalebJamesStevens avatar Aug 23 '22 22:08 CalebJamesStevens

I got the same error when using the "useId" hook in React Native.

I have tried to solve the issue. I only change versions of React and React native both as below. After that, the error was gone!

"react": "18.2.0", "react-native": " 0.70"

pavankwebelight avatar Oct 20 '22 06:10 pavankwebelight

@PrimozRome Please provide a CodeSandbox reproducing the issue.

I have managed to solve the issue. I only upgraded react but not react-dom. After that, the error was gone!

And what is your version of react-dom ?

vaukalak avatar Dec 02 '22 13:12 vaukalak

Updating react, react-dom and react-scripts to their latest version works: https://codesandbox.io/s/bold-shannon-53uc9j?file=/src/index.tsx I am closing the issue as no one created any reproduction.

mnajdova avatar Dec 02 '22 13:12 mnajdova

I got the same error with [email protected] and solved it by upgrading react-dom to 18.2.0

nivapo95 avatar Dec 28 '22 16:12 nivapo95

I got the same error with [email protected] and solved it by upgrading react-dom to 18.2.0

this solution worked for me upgrading react-dom to 18.2.0

Chandra6160 avatar Oct 04 '23 07:10 Chandra6160