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

bug: useRequest 设置debounceInterval,报 Cannot read property 'now' of undefined #15

Closed
Apigflying opened this issue Dec 24, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Apigflying
Copy link

使用useRequest 时,在小程序里,会报Cannot read property 'now' of undefined 的错误

  • taro-hooks: latest
  • taro: 3.3.10
  • node: 14.13.0

复现步骤

在使用useRequest,并且使用了debounceInterval,会报上述错误
查看源代码 是 p.Date.now 报错,应该是 ahook的问题,我单独使用ahook里的防抖和节流函数也会报这个错误

@Apigflying Apigflying added the bug Something isn't working label Dec 24, 2021
@innocces innocces self-assigned this Dec 24, 2021
@innocces
Copy link
Owner

可以提供一下代码片段嘛? 目前在官网示例中是有debounceInterval的示例的。

@innocces
Copy link
Owner

innocces commented Dec 24, 2021

=。- lodash.debounce的锅。在小程序中拿不到global导致self.Date.now()报错了。晚上发一个修复版本修复一下这个问题。

https://github.com/lodash/lodash/blob/master/.internal/root.js#L11

@Apigflying
Copy link
Author

=。- lodash.debounce的锅。在小程序中拿不到global导致self.Date.now()报错了。晚上发一个修复版本修复一下这个问题。

https://github.com/lodash/lodash/blob/master/.internal/root.js#L11

ahooks 里的useDebounce 和 useThrottle 也都有这个问题
不知道之后会不会在taro-hooks 里加这两个hook

@innocces
Copy link
Owner

=。- lodash.debounce的锅。在小程序中拿不到global导致self.Date.now()报错了。晚上发一个修复版本修复一下这个问题。
https://github.com/lodash/lodash/blob/master/.internal/root.js#L11

ahooks 里的useDebounce 和 useThrottle 也都有这个问题 不知道之后会不会在taro-hooks 里加这两个hook

后面会开启2.0的RFCS. 可以在里面写一下期望有的hooks. 按照顺序会慢慢的都更新进来。但是和环境无关的hooks基本不会重复造轮子。

@innocces
Copy link
Owner

fixed in v1.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants