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

升级到React 18后,异步请求后出现警告 Template tmpl_0_view not found,小程序功能几乎不受影响,react 17下无此情况 #12558

Closed
kityandhero opened this issue Sep 22, 2022 · 2 comments · Fixed by #12662
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@kityandhero
Copy link

kityandhero commented Sep 22, 2022

相关平台

微信小程序

复现仓库

https://github.com/kityandhero/taro-fast-template
小程序基础库: 2.2.26
使用框架: React

复现步骤

pnpm instal

npm start

加载首页后,控制台可看到警告信息

期望结果

不出现 [WXML Runtime warning] ./base.wxml
Template tmpl_0_view not found.

实际结果

出现警告 Template tmpl_0_view not found.

环境信息

👽 Taro v3.5.6


  Taro CLI 3.5.6 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 16.14.0 - ~\AppData\Local\fnm_multishells\25184_1663838964274\node.EXE
      Yarn: 1.22.18 - D:\node\npm\node_global\yarn.CMD
      npm: 8.3.1 - ~\AppData\Local\fnm_multishells\25184_1663838964274\npm.CMD

补充信息

自更新至 react 18后出现,在 react 17 下无此警告,仅出现在小程序中,H5无此问题。

该警告触发场景为:页面首次render后请求远程接口,短时间内请求完毕之后更新state项, 之后再次render,页面将出现这个警告。

将排查到的可能节点内置children 替换成 数字后警告消失,将节点children变更为<View>0</View>之类极简内容,此警告依然存在,且警告仅出现在异步请求回调场景下, 调测的节点都为异步请求后渲染的节点。

这个警告对小程序功能的影响基本没有,一个页面只提示一次。

<template name="tmpl_0_container">
<template is="{{xs.a(0, i.nn, l)}}" data="{{i:i,cid:0,l:xs.f(l,i.nn)}}" />
</template>

调试编译后的文件发现传入的 i.nn 值为 "view" 字符串,正常情况下一般为数字。初步估计和react 18 的 setState 调整有关,问题根源暂未找到。

示例中的异步请求为通过settimeout模拟, 与真实请求接口行为的场景基本一致,小程序基于自行封装的 framework 运行,经排测,好像与 framework 关系不大。

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Sep 22, 2022
@TheKonka
Copy link
Member

image
我这老项目升级后也会出现类似的问题,但是还不清楚具体触发场景和原因

@Chen-jj
Copy link
Contributor

Chen-jj commented Oct 16, 2022

@kityandhero @TheKonka 感谢反馈~原因是当元素嵌套层级默认超过 16 层后,Taro 会启用自定义组件 comp 重新开始 template 的递归。而此自定义组件的用于接收对应 DOM 树数据结构的 property,它的默认值目前使用了 view,所以会导致 warning。应该改为使用 view 对应的数字别名。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants