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

renderFunction 定义在 render 方法之后,或为匿名函数,会被识别成 renderProps #3966

Closed
Darmody opened this issue Jul 26, 2019 · 6 comments

Comments

@Darmody
Copy link

Darmody commented Jul 26, 2019

问题描述
renderFunction 如果定义为匿名函数,或者定义在了 render 方法之后,会被识别成 renderProps, import 无用的 SuperClass

复现步骤
在 render 方法之后定义 renderFunction,或者将 render 方法定义为匿名函数

期望行为
正确识别 render 函数

报错信息
屏幕快照 2019-07-26 10 46 35

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。

  • 操作系统: Mac
  • Taro 版本 1.3.6
  • Node.js 版本 11
  • 报错平台 weapp

补充信息
renderFunction如果定义为匿名函数,或者定义在了 render 方法之后,self.methods 里就不会包含这个 render 函数,因此会被认为是 renderProps,从而会把 SuperClass import 进来。

@taro-bot
Copy link

taro-bot bot commented Jul 26, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@yuche
Copy link
Contributor

yuche commented Jul 26, 2019

Duplicate of #3914

@yuche yuche marked this as a duplicate of #3914 Jul 26, 2019
@yuche
Copy link
Contributor

yuche commented Jul 26, 2019

下个版本 ESLint 会规范你的组件生命周期顺序

@yuche yuche closed this as completed Jul 26, 2019
@Darmody
Copy link
Author

Darmody commented Jul 26, 2019

@yuche 这不算是解决方法吧?如果我用 typescript ,更倾向于把方法都定义为私有方法,而且匿名函数也是需要的

@yuche
Copy link
Contributor

yuche commented Jul 26, 2019

你私有与否不影响 ESLint 的运行

@Darmody
Copy link
Author

Darmody commented Jul 26, 2019

你私有与否不影响 ESLint 的运行

因为 private 方法从风格上来说,应该放在public 方法后面

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

No branches or pull requests

2 participants