Taro: 3.0.0-rc3 引入react-query 报错

Created on 4 Jun 2020  ·  5Comments  ·  Source: NervJS/taro

问题描述

直接引入react-query后项目启动报错

复现步骤

  1. npm i --save react-query
  2. 启动小程序端项目 npm run dev:weapp
默认首页代码
import React, { Component } from 'react'
import { View, Text } from '@tarojs/components'
import './index.less'

export default class Index extends Component {

  componentWillMount () { }

  componentDidMount () { }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  render () {
    return (
      <View className='index'>
        <Text>Hello world!</Text>
      </View>
    )
  }
}


期望行为

是否可以直接支持react相关库?

报错信息

The above error occurred in the <AppWrapper> component:
    in AppWrapper

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
console.error @ VM469:1
logCapturedError @ react-reconciler.development.js:11825
logError @ react-reconciler.development.js:11825
update.callback @ react-reconciler.development.js:13207
callCallback @ react-reconciler.development.js:3590
commitUpdateEffects @ react-reconciler.development.js:3631
commitUpdateQueue @ react-reconciler.development.js:3630
commitLifeCycles @ react-reconciler.development.js:12116
commitLayoutEffects @ react-reconciler.development.js:15314
invokeGuardedCallbackImpl @ react-reconciler.development.js:11540
invokeGuardedCallback @ react-reconciler.development.js:11712
commitRootImpl @ react-reconciler.development.js:15053
unstable_runWithPriority @ scheduler.development.js:817
runWithPriority @ react-reconciler.development.js:1823
commitRoot @ react-reconciler.development.js:14858
finishSyncRender @ react-reconciler.development.js:14304
performSyncWorkOnRoot @ react-reconciler.development.js:14287
(anonymous) @ react-reconciler.development.js:1910
unstable_runWithPriority @ scheduler.development.js:817
runWithPriority @ react-reconciler.development.js:1823
flushSyncCallbackQueueImpl @ react-reconciler.development.js:1905
flushSyncCallbackQueue @ react-reconciler.development.js:1899
scheduleUpdateOnFiber @ react-reconciler.development.js:13692
enqueueForceUpdate @ react-reconciler.development.js:3746
push../node_modules/react/cjs/react.development.js.Component.forceUpdate @ react.development.js:489
mount @ react.ts:96
mount @ react.ts:165
onLoad @ common.ts:108
(anonymous) @ VM485 WAService.js:2
p.__callPageLifeTime__ @ VM485 WAService.js:2
jt @ VM485 WAService.js:2
(anonymous) @ VM485 WAService.js:2
Mt @ VM485 WAService.js:2
(anonymous) @ VM485 WAService.js:2
(anonymous) @ VM485 WAService.js:2
i.emit @ VM485 WAService.js:2
emit @ VM485 WAService.js:2
(anonymous) @ VM485 WAService.js:2
i.emit @ VM485 WAService.js:2
emit @ VM485 WAService.js:2
(anonymous) @ VM485 WAService.js:2
(anonymous) @ VM485 WAService.js:2
n @ VM483 asdebug.js:1
(anonymous) @ VM483 asdebug.js:1
(anonymous) @ VM483 asdebug.js:1
_ws.onmessage @ VM483 asdebug.js:1
Show 16 more frames
VM469:1 thirdScriptError
没有找到页面实例。
如有疑问,请提交 issue 至:https://github.com/nervjs/taro/issues;at "pages/index/index" page lifeCycleMethod onLoad function
Error: 没有找到页面实例。
如有疑问,请提交 issue 至:https://github.com/nervjs/taro/issues
    at ensure (http://127.0.0.1:48487/appservice/taro.js:7948:9)
    at AppWrapper.<anonymous> (http://127.0.0.1:48487/appservice/taro.js:10775:9)
    at callCallback (http://127.0.0.1:48487/appservice/app.js:663:357)
    at commitUpdateEffects (http://127.0.0.1:48487/appservice/app.js:670:387)
    at commitUpdateQueue (http://127.0.0.1:48487/appservice/app.js:670:1)
    at commitLifeCycles (http://127.0.0.1:48487/appservice/app.js:1917:1)
    at commitLayoutEffects (http://127.0.0.1:48487/appservice/app.js:2514:172)
    at Object.invokeGuardedCallbackImpl (http://127.0.0.1:48487/appservice/app.js:1782:236)
    at invokeGuardedCallback (http://127.0.0.1:48487/appservice/app.js:1863:126)
    at commitRootImpl (http://127.0.0.1:48487/appservice/app.js:2469:57)

系统信息

Taro v3.0.0-rc.3

Taro CLI 3.0.0-rc.3 environment info:
System:
OS: macOS 10.14.4
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.12.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
npmPackages:
@tarojs/components: 3.0.0-rc.3 => 3.0.0-rc.3
@tarojs/mini-runner: 3.0.0-rc.3 => 3.0.0-rc.3
@tarojs/react: 3.0.0-rc.3 => 3.0.0-rc.3
@tarojs/runtime: 3.0.0-rc.3 => 3.0.0-rc.3
@tarojs/taro: 3.0.0-rc.3 => 3.0.0-rc.3
@tarojs/webpack-runner: 3.0.0-rc.3 => 3.0.0-rc.3
babel-preset-taro: 3.0.0-rc.3 => 3.0.0-rc.3
eslint-config-taro: 3.0.0-rc.3 => 3.0.0-rc.3
react: ^16.10.0 => 16.13.1

question

All 5 comments

这个包用了 fetch,不能直接使用

这个包用了 fetch,不能直接使用

我看了下源码 不应该是用了fetch吧 react 的 context、memo、callback在taro3 中都支持么

@yuche react-query 没有使用 fetch,它的请求接口是暴露给用户自定义的。
3.0.0.rc-5 可以引入,但是出现 maximum update depth exceed: https://github.com/NervJS/taro/issues/6739

@yuche react-query 没有使用 fetch,它的请求接口是暴露给用户自定义的。
3.0.0.rc-5 可以引入,但是出现 maximum update depth exceed: #6739

后来我直接把react-query的源码拉下来复制到项目里面中是可以启动并使用的,就是不知道有没有隐患

duplicate #6739

Was this page helpful?
0 / 5 - 0 ratings