lowcode-engine icon indicating copy to clipboard operation
lowcode-engine copied to clipboard

低代码组件shouldComponentUpdate不生效

Open zsj9705 opened this issue 2 years ago • 4 comments

Describe the bug (required) / 详细描述 bug(必填)

低代码组件中使用shouldComponentUpdate返回false,在低代码组件中更新state时可以执行shouldComponentUpdate方法。 在页面中更新state时,这个低代码组件的shouldComponentUpdate不会执行。


To Reproduce (required) / 如何复现 bug?(必填,非常重要)

Steps to reproduce the behavior: / 详细复现步骤:

  1. 使用该仓库给低代码组件增加shouldComponentUpdate,返回false https://github.com/alibaba/lowcode-demo/tree/main/demo-lowcode-component
  2. 在页面中增加按钮加入点击事件更新state。
  3. 控制台打印执行了低代码组件的componentDidUpdate,并没有触发shouldComponentUpdate。
  4. 如果是低代码组件内事件更新了内部state,可以触发shouldComponentUpdate。

Expected behavior (required) / 预期行为(必填,非常重要)

A clear and concise description of what did you expect to happen. / 请清晰和精确的描述你预期的行为

想在低代码组件中使用shouldComponentUpdate来避免一些重渲染

Screenshots (optional) / bug 截图(可选)

Sceenshots for further information. (If applicable.) / 一些有用的截图将会帮助我们更好的明确以及定位问题


Environments (please complete the following information) (required): / 请提供如下信息(必填)

  • AliLowCodeEngine version: [e.g. 1.0.0] / 低代码引擎版本
  • AliLowCodeEngineExt version: [e.g. 1.0.0] / 低代码引擎扩展包版本
  • Browser [e.g. chrome, safari] / 浏览器版本
  • materials / plugins / tools / 其他物料 / 插件 / 工具链版本

(this information can be collected via the manual plugin / 版本信息可通过低代码用户手册插件收集)

Additional context (optional) / 更多额外信息(可选)

Any other context of the problem here. / 可以追加更多的额外信息,帮助定位问题

zsj9705 avatar Dec 22 '23 03:12 zsj9705

这个生命周期不是不建议使用了吗?

zhuyuanmin avatar Dec 26 '23 10:12 zhuyuanmin

这个生命周期是不是不建议使用了?

如果使用低代码组件的话,我们需要使用shouldComponentUpdate做一些跳过重渲染的优化。 这个生命周期react官方没有说不建议使用。在类组件中只能用PureComponent或者shouldComponentUpdate来做一些渲染优化。低代码引擎文档中是没有说明shouldComponentUpdate这个生命周期

zsj9705 avatar Dec 27 '23 01:12 zsj9705

这个生命周期是不是不建议使用了?

如果使用低代码组件的话,我们需要使用shouldComponentUpdate做一些跳过重渲染的优化。 这个生命周期react官方没有说不建议使用。在类组件中只能用PureComponent或者shouldComponentUpdate来做一些渲染优化。低代码引擎文档中是没有说明shouldComponentUpdate这个生命周期

@zsj9705 嗯。React 官方只是不建议使用类组件了。 在低代码渲染模型中低代码组件的渲染不一定使用类组件来渲染,所以不一定支持该生命周期

1ncounter avatar Dec 27 '23 02:12 1ncounter

这个生命周期是不是不建议使用了?

如果使用低代码组件的话,我们需要使用shouldComponentUpdate做一些跳过重渲染的优化。 这个生命周期react官方没有说不建议使用。在类组件中只能用PureComponent或者shouldComponentUpdate来做一些渲染优化。低代码引擎文档中是没有说明shouldComponentUpdate这个生命周期

@zsj9705 嗯。React 官方只是不建议使用类组件了。 在低代码渲染模型中低代码组件的渲染不一定使用类组件来渲染,所以不一定支持该生命周期

使用造物产出的低代码组件是用的类组件,这种低代码组件怎么使用shouldComponentUpdate方法来做渲染优化呢? image

zsj9705 avatar Dec 27 '23 03:12 zsj9705