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

1.3.0 beta.1 使用 hooks 构建微信小程序报错 #3000

Closed
yinLiangDream opened this issue May 9, 2019 · 5 comments
Closed

1.3.0 beta.1 使用 hooks 构建微信小程序报错 #3000

yinLiangDream opened this issue May 9, 2019 · 5 comments

Comments

@yinLiangDream
Copy link

import Taro , { useState } from '@tarojs/taro';
function Example {
  const [selected, setSelected] = useState('');
  return <View>{selected}</View>
}

编译不错,但是小程序报错
报错如下
image

查看代码是这个未定义
image

正常编译下是这个
image

@taro-bot
Copy link

taro-bot bot commented May 9, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@yinLiangDream
Copy link
Author

我研究了下,是编译的问题,如果这个编译成

// (Taro.Component) 改成
(_index.default.Component)

就没有问题了,hooks 也是生效的,希望改一下orz

@MarvinShawn
Copy link

我研究了下,是编译的问题,如果这个编译成

// (Taro.Component) 改成
(_index.default.Component)

就没有问题了,hooks 也是生效的,希望改一下orz

俺也一样

@yuche
Copy link
Contributor

yuche commented May 9, 2019

typescript 默认会把 没有用到的 import 移除,Taro 被移除掉了所以没能编译出来。

你可以在文件里写个 console.log(Taro) 或者使用 js。

@yuche
Copy link
Contributor

yuche commented May 9, 2019

close via 866aca1

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

3 participants