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

使用recoil无法正常使用: Illegal invocatio #10119

Closed
liuhuapiaoyuan opened this issue Aug 25, 2021 · 20 comments · Fixed by #10697 or #10721
Closed

使用recoil无法正常使用: Illegal invocatio #10119

liuhuapiaoyuan opened this issue Aug 25, 2021 · 20 comments · Fixed by #10697 or #10721
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@liuhuapiaoyuan
Copy link

相关平台

微信小程序

小程序基础库: 2.16.0
使用框架: React

复现步骤

配置recoil,启动后失败

期望结果

正常使用

实际结果

TypeError: Illegal invocation
    at VM1563 vendors.js:12146
    at jh (VM1563 vendors.js:6843)
    at exports.unstable_runWithPriority (VM1563 vendors.js:15691)
    at Pc (VM1563 vendors.js:6703)
    at Qg (VM1563 vendors.js:6841)
    at Og (VM1563 vendors.js:6827)
    at VM1563 vendors.js:6704
    at exports.unstable_runWithPriority (VM1563 vendors.js:15691)
    at Pc (VM1563 vendors.js:6703)
    at Rc (VM1563 vendors.js:6704)

环境信息

  Taro CLI 3.3.3 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 14.15.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.23.0-20200615.1913 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Aug 25, 2021
@TomVista
Copy link
Contributor

目前只有redux 和mobx 的支持

@arniu
Copy link
Contributor

arniu commented Aug 30, 2021

根据教程 / 其它状态管理工具,Recoil 是支持的。

@liuhuapiaoyuan
Copy link
Author

liuhuapiaoyuan commented Aug 30, 2021

是的 之前我是使用过的。现在这个3.3好像有点问题

vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:7512 TypeError: Illegal invocation
    at vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:12863
    at jh (vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:7560)
    at define.push../node_modules/scheduler/cjs/scheduler.production.min.js.exports.unstable_runWithPriority (vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:16408)
    at Pc (vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:7420)
    at Qg (vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:7558)
    at Og (vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:7544)
    at vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:7421
    at define.push../node_modules/scheduler/cjs/scheduler.production.min.js.exports.unstable_runWithPriority (vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:16408)
    at Pc (vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:7420)
    at Rc (vendors.js?t=wechat&s=1629886562607&v=a5c937e72344b9ff4b8c62f08cca59e7:7421)

@itcat99
Copy link

itcat99 commented Sep 13, 2021

同样的问题,目前去 nodule_modules/recoil/es/recoil.js里面,添加一行

window = global;

可以暂时解决。

版本:

  • recoil: 0.4.1
  • taro: 3.3.7

@loethen
Copy link

loethen commented Nov 2, 2021

我也遇到同样的问题

@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 2, 2021

@loethen Illegal invocation 一般是 setTimeout.call(context) 这样调用时,context 错误导致。之前 Taro 给 requestAnimationFrame 模拟函数里的 setTimeout 绑了一个错误的 context,后来已经改了。可以升级到最新版再试试。

https://github.com/NervJS/taro/pull/10311/files

@loethen
Copy link

loethen commented Nov 2, 2021

@Chen-jj 更新到3.3.12依然不行

@skyliwq
Copy link

skyliwq commented Nov 14, 2021

3.3.14 下 TypeError: Illegal invocation Recoil 还是无法使用希望尽快解决啊 大佬

@skyliwq
Copy link

skyliwq commented Nov 14, 2021

@Chen-jj 更新到3.3.12依然不行

3.3.14 下 TypeError: Illegal invocation Recoil 还是无法使用希望尽快解决啊 大佬

@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 14, 2021

@skyliwq 提供一下 demo?

@skyliwq
Copy link

skyliwq commented Nov 15, 2021

@Chen-jj 更新到3.3.12依然不行

3.3.14 下 TypeError: Illegal invocation Recoil 还是无法使用希望尽快解决啊 大佬

import {useEffect} from 'react'
import {atom, useRecoilState} from "recoil";

import { View } from '@tarojs/components'
import {AtButton } from 'taro-ui'

const tokenState = atom({
key: 'tokenState',
default: '出来拉',
});

const Index = () => {
const [token, setToken] = useRecoilState(tokenState);

return (
  <View className='index'>
    <AtButton
      onClick={()=>{
        setToken('回去吧')
      }}
    >Hello world!{token}</AtButton>
  </View>
)

}
export default Index

@skyliwq
Copy link

skyliwq commented Nov 17, 2021

@Chen-jj 更新到3.3.12依然不行

3.3.14 下 Recoil 打包出现 setTimeout is not a function 错误 无法完成打包 白做了!!!

@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 17, 2021

我们看看

@Chen-jj Chen-jj added this to the 3.3.15 milestone Nov 22, 2021
Chen-jj added a commit that referenced this issue Nov 22, 2021
封装 window.setTimeout、window.clearTimeout,避免第三方库使用 window.setTimeout 调用时,Taro 封装的 window 对象和真正挂载 setTimeout 的 global 对象不一样时,报 Illegal invocation 的问题
Chen-jj added a commit that referenced this issue Nov 22, 2021
封装 window.setTimeout、window.clearTimeout,避免第三方库使用 window.setTimeout 调用时,Taro 封装的 window 对象和真正挂载 setTimeout 的 global 对象不一样时,报 Illegal invocation 的问题
@skyliwq
Copy link

skyliwq commented Dec 1, 2021

我们看看

image

3.3.15 依旧无法使用,不知道为什么,微信开发工具已更新最新版,还是出现这样问题

@skyliwq
Copy link

skyliwq commented Dec 1, 2021

@Chen-jj 更新到3.3.12依然不行
大神帮忙看一下!!

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 1, 2021

@skyliwq 上一个完整的 demo 看看

@skyliwq
Copy link

skyliwq commented Dec 1, 2021

@Chen-jj 更新到3.3.15依然不行
大神帮忙看一下!!
https://github.com/skyliwq/taro-recoil-demo.git
微信开发工具 1.05.2110290 MAC

@skyliwq
Copy link

skyliwq commented Dec 7, 2021

@Chen-jj 更新到3.3.15依然不行
大神帮忙看一下!!等着上线呀

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 7, 2021

@skyliwq 你的 demo 里 Taro 相关依赖还是 3.3.14,升上去最新版就好了

@damon35868
Copy link

damon35868 commented Sep 20, 2022

3.5.2打包到字节小程序依然报错Illegal invocation,微信小程序正常,求解决 @Chen-jj

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
8 participants