Skip to content

Preact TypeError: ReactDOM$1.createRoot is not a function #16690

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

Closed
hanxinimm opened this issue Oct 12, 2024 · 13 comments · Fixed by #17461
Closed

Preact TypeError: ReactDOM$1.createRoot is not a function #16690

hanxinimm opened this issue Oct 12, 2024 · 13 comments · Fixed by #17461

Comments

@hanxinimm
Copy link

相关平台

微信小程序

小程序基础库: 2.33.0
使用框架: React

复现步骤

初始化项目 taro init myApp
选择Preact
编译可以成功,小程序打开控制台报错

期望结果

正常运行

实际结果

app.js错误:
TypeError: y.createRoot is not a function
at T (taro.js? [sm]:1)
at Y (taro.js? [sm]:1)
at Module._ (app.js? [sm]:1)
at l (runtime.js? [sm]:1)
at t (runtime.js? [sm]:1)
at Array.r [as push] (runtime.js? [sm]:1)
at app.js? [sm]:1
at S (WASubContext.js?t=wechat&s=1728721266612&v=2.28.1:1)
at appservice.js:7
at doWhenAllScriptLoaded (getmainpackage.js:7361)(env: Windows,mp,1.06.241
0102; lib: 2.28.1)

环境信息

Taro v4.0.6


  Taro CLI 4.0.6 environment info:
    System:
      OS: Windows 10 10.0.19045
    Binaries:
      Node: 18.20.4 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
      npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.6 => 4.0.6
      @tarojs/components: 4.0.6 => 4.0.6
      @tarojs/helper: 4.0.6 => 4.0.6
      @tarojs/plugin-framework-react: 4.0.6 => 4.0.6
      @tarojs/plugin-html: 4.0.6 => 4.0.6
      @tarojs/plugin-platform-alipay: 4.0.6 => 4.0.6
      @tarojs/plugin-platform-h5: 4.0.6 => 4.0.6
      @tarojs/plugin-platform-jd: 4.0.6 => 4.0.6
      @tarojs/plugin-platform-qq: 4.0.6 => 4.0.6
      @tarojs/plugin-platform-swan: 4.0.6 => 4.0.6
      @tarojs/plugin-platform-tt: 4.0.6 => 4.0.6
      @tarojs/plugin-platform-weapp: 4.0.6 => 4.0.6
      @tarojs/runtime: 4.0.6 => 4.0.6
      @tarojs/shared: 4.0.6 => 4.0.6
      @tarojs/taro: 4.0.6 => 4.0.6
      @tarojs/vite-runner: 4.0.6 => 4.0.6
      babel-preset-taro: 4.0.6 => 4.0.6
      eslint-config-taro: 4.0.6 => 4.0.6
@hanxinimm
Copy link
Author

救命啊,旧的项目编译失败,升级到新的,又无法使用,现在要修改旧的版本代码,卡进度了 @Chen-jj 打工人,江湖救急

@dinfer
Copy link

dinfer commented Oct 13, 2024

npx @tarojs/cliinit xxx 方式创建项目遇到同样问题。cli 的版本为 4.0.5

? 请输入项目介绍 health
? 请选择框架 PReact
? 是否需要使用 TypeScript ? Yes
? 请选择 CSS 预处理器(Sass/Less/Stylus) 无
? 请选择包管理工具 npm
? 请选择编译工具 Vite
? 请选择模板源 Github(最新)
✔ 拉取远程模板仓库成功!
? 请选择模板 默认模板

@LonelySteve
Copy link

preact 版本问题,最新版的 preact/compat 导出的 version 是 18.x,并且调整了导出路径,改为像 React 18 一样采用 react-dom/client 来导出 createRoot 方法,这似乎没被 Taro 正确处理,折腾了一会我还是回到了之前的版本,目前来看,preact 10.20.2 是可用的

@ijntvwh
Copy link

ijntvwh commented Oct 21, 2024

同样,第一步就卡住了,这体验......

@dasensen
Copy link

同样遇到了这个问题,退回了 react

@heshine0
Copy link

heshine0 commented Dec 3, 2024

这个bug怎么修复呢

preact 版本问题,最新版的 preact/compat 导出的 version 是 18.x,并且调整了导出路径,改为像 React 18 一样采用 react-dom/client 来导出 createRoot 方法,这似乎没被 Taro 正确处理,折腾了一会我还是回到了之前的版本,目前来看,preact 10.20.2 是可用的

@hanxinimm
Copy link
Author

preact 10.20.2
这个库使用这个版本就好

@wonglae
Copy link

wonglae commented Dec 30, 2024

最新taro 4.0.8似乎还有其他问题,回退preact到10.20.2之后index 页面显示空白,回退taro到4.0.6问题解决

@czfadmin
Copy link

czfadmin commented Jan 3, 2025

最新taro 4.0.8似乎还有其他问题,回退preact到10.20.2之后index 页面显示空白,回退taro到4.0.6问题解决

回退preact的我4.08可以

@wzq-taxun
Copy link

app.js错误:
TypeError: ReactDOM$1.createRoot is not a function 项目突然不行了 有啥解决办法

@wzq-taxun
Copy link

preact 10.20.2
这个库使用这个版本就好

还是不行 不知道咋搞了 头大

@hanxinimm
Copy link
Author

preact 10.20.2
这个库使用这个版本就好

还是不行 不知道咋搞了 头大

你的项目只留下一个启动页面,上传下或者发个链接,我给你看看

@ananiahfox
Copy link

preact 10.20.2
这个库使用这个版本就好

还是不行 不知道咋搞了 头大

我的也不行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants