Giter Club home page Giter Club logo

Comments (15)

github-actions avatar github-actions commented on May 10, 2024

Hello @gooddaddy. In order to facilitate location and troubleshooting, we need you to provide a realistic example. You can create a taro project by clicking here and provide the GitHub warehouse address and reproduce examples.

你好 @gooddaddy, 为了方便定位和排查问题,我们需要你提供一个重现实例。你可以通过点击 此处 创建一个 Taro 项目并提供 GitHub 仓库地址和重现实例。

from taro-hooks.

gooddaddy avatar gooddaddy commented on May 10, 2024

Hello @gooddaddy. In order to facilitate location and troubleshooting, we need you to provide a realistic example. You can create a taro project by clicking here and provide the GitHub warehouse address and reproduce examples.

你好 @gooddaddy, 为了方便定位和排查问题,我们需要你提供一个重现实例。你可以通过点击 此处 创建一个 Taro 项目并提供 GitHub 仓库地址和重现实例。

一.编译过了,但是目前类型有问题;
declare function useRequest<TData, TParams extends any[]>(service: Service<TData, TParams>, options?: Options<TData, TParams>, plugins?: Plugin<TData, TParams>[]): import("./types").Result<TData, TParams> | undefined;

为啥useRequest 返回值可能是 undefined 的?这样会导致 调用useRequest后不能直接解构。

二.运行时 报错

.._src_runtime_connect.ts:275 TypeError: Object(...) is not a function
at useLatest (.node_modules@taro-hooks_ahooks_es_useLatest_index.js:4)
at useRequestImplement (.node_modules@taro-hooks_use-request_es_useRequestImplement.js:30)
at useRequest (.node_modules@taro-hooks_use-request_es_useRequest.js:12)
at ._src_pages_home_index.tsx:54
at .._src_observer.ts:104
at .._src_useObserver.ts:115
at trackDerivedFunction (.._src_core_derivation.ts:183)
at Reaction.track (.._src_core_reaction.ts:137)
at useObserver (.._src_useObserver.ts:113)
at observerComponent (.._src_observer.ts:104)(env: macOS,mp,1.06.2208010; lib: 2.25.1)
找到对应的源码 发现:
image

from taro-hooks.

innocces avatar innocces commented on May 10, 2024

Hello @gooddaddy. In order to facilitate location and troubleshooting, we need you to provide a realistic example. You can create a taro project by clicking here and provide the GitHub warehouse address and reproduce examples.
你好 @gooddaddy, 为了方便定位和排查问题,我们需要你提供一个重现实例。你可以通过点击 此处 创建一个 Taro 项目并提供 GitHub 仓库地址和重现实例。

一.编译过了,但是目前类型有问题; declare function useRequest<TData, TParams extends any[]>(service: Service<TData, TParams>, options?: Options<TData, TParams>, plugins?: Plugin<TData, TParams>[]): import("./types").Result<TData, TParams> | undefined;

为啥useRequest 返回值可能是 undefined 的?这样会导致 调用useRequest后不能直接解构。

二.运行时 报错

.._src_runtime_connect.ts:275 TypeError: Object(...) is not a function at useLatest (.node_modules@taro-hooks_ahooks_es_useLatest_index.js:4) at useRequestImplement (.node_modules@taro-hooks_use-request_es_useRequestImplement.js:30) at useRequest (.node_modules@taro-hooks_use-request_es_useRequest.js:12) at ._src_pages_home_index.tsx:54 at .._src_observer.ts:104 at .._src_useObserver.ts:115 at trackDerivedFunction (.._src_core_derivation.ts:183) at Reaction.track (.._src_core_reaction.ts:137) at useObserver (.._src_useObserver.ts:113) at observerComponent (.._src_observer.ts:104)(env: macOS,mp,1.06.2208010; lib: 2.25.1) 找到对应的源码 发现: image

  1. 若请求发生失败或者出错的过程。data可能是为空的. 并且初始是data也是undefined
  2. 运行时报错可以参考一下框架配置。看下是不是有配置没有引入。配置

from taro-hooks.

gooddaddy avatar gooddaddy commented on May 10, 2024

若请求发生失败或者出错的过程。data可能是为空的. 并且初始是data也是undefined
data 为空正常,但是 你这里是 函数 返回都是是空,ahooks 里面的 useRequest 返回类型都不是这样的,你是不是写错了?

from taro-hooks.

innocces avatar innocces commented on May 10, 2024

若请求发生失败或者出错的过程。data可能是为空的. 并且初始是data也是undefined
data 为空正常,但是 你这里是 函数 返回都是是空,ahooks 里面的 useRequest 返回类型都不是这样的,你是不是写错了?

是一样的 Tdata

from taro-hooks.

gooddaddy avatar gooddaddy commented on May 10, 2024

若请求发生失败或者出错的过程。data可能是为空的. 并且初始是data也是undefined
data 为空正常,但是 你这里是 函数 返回都是是空,ahooks 里面的 useRequest 返回类型都不是这样的,你是不是写错了?

是一样的 Tdata

这是 ahooks的类型声明:

import type { Options, Plugin, Service } from './types';
declare function useRequest<TData, TParams extends any[]>(service: Service<TData, TParams>, options?: Options<TData, TParams>, plugins?: Plugin<TData, TParams>[]): import("./types").Result<TData, TParams>;
export default useRequest;

这是你的声明:

import type { Options, Plugin, Service } from './types';
declare function useRequest<TData, TParams extends any[]>(service: Service<TData, TParams>, options?: Options<TData, TParams>, plugins?: Plugin<TData, TParams>[]): import("./types").Result<TData, TParams> | undefined;
export default useRequest;

你的在后面 | undefined

from taro-hooks.

innocces avatar innocces commented on May 10, 2024

额。可能是编译的锅。这个我得看看

from taro-hooks.

gooddaddy avatar gooddaddy commented on May 10, 2024

额。可能是编译的锅。这个我得看看

帮忙看看,另外一个问题,我用taro cli 创建一个最新的工程,然后按照你的方式配置,工程能编译通过,但是运行报错(目前最新的taro 是3.5.5 工程默认是 webpack5的,你的插件是不是 不支持webpack5?)

from taro-hooks.

innocces avatar innocces commented on May 10, 2024

额。可能是编译的锅。这个我得看看

帮忙看看,另外一个问题,我用taro cli 创建一个最新的工程,然后按照你的方式配置,工程能编译通过,但是运行报错(目前最新的taro 是3.5.5 工程默认是 webpack5的,你的插件是不是 不支持webpack5?)

空的项目么?

from taro-hooks.

gooddaddy avatar gooddaddy commented on May 10, 2024

额。可能是编译的锅。这个我得看看

帮忙看看,另外一个问题,我用taro cli 创建一个最新的工程,然后按照你的方式配置,工程能编译通过,但是运行报错(目前最新的taro 是3.5.5 工程默认是 webpack5的,你的插件是不是 不支持webpack5?)

空的项目么?
工程向导中选择:react 、typescript 、webpack5 创建工程

from taro-hooks.

innocces avatar innocces commented on May 10, 2024

node 版本可以提供一下么

from taro-hooks.

gooddaddy avatar gooddaddy commented on May 10, 2024

node 版本可以提供一下么

node 8.5.0

package.json

{
  "name": "myApp",
  "version": "1.0.0",
  "private": true,
  "description": "",
  "templateInfo": {
    "name": "default",
    "typescript": true,
    "css": "sass"
  },
  "scripts": {
    "build:weapp": "taro build --type weapp",
    "build:swan": "taro build --type swan",
    "build:alipay": "taro build --type alipay",
    "build:tt": "taro build --type tt",
    "build:h5": "taro build --type h5",
    "build:rn": "taro build --type rn",
    "build:qq": "taro build --type qq",
    "build:jd": "taro build --type jd",
    "build:quickapp": "taro build --type quickapp",
    "dev:weapp": "npm run build:weapp -- --watch",
    "dev:swan": "npm run build:swan -- --watch",
    "dev:alipay": "npm run build:alipay -- --watch",
    "dev:tt": "npm run build:tt -- --watch",
    "dev:h5": "npm run build:h5 -- --watch",
    "dev:rn": "npm run build:rn -- --watch",
    "dev:qq": "npm run build:qq -- --watch",
    "dev:jd": "npm run build:jd -- --watch",
    "dev:quickapp": "npm run build:quickapp -- --watch"
  },
  "browserslist": [
    "last 3 versions",
    "Android >= 4.1",
    "ios >= 8"
  ],
  "author": "",
  "dependencies": {
    "@babel/runtime": "^7.7.7",
    "@tarojs/components": "3.5.5",
    "@tarojs/helper": "3.5.5",
    "@tarojs/mini-runner": "^3.5.5",
    "@tarojs/plugin-framework-react": "3.5.5",
    "@tarojs/plugin-platform-alipay": "3.5.5",
    "@tarojs/plugin-platform-jd": "3.5.5",
    "@tarojs/plugin-platform-qq": "3.5.5",
    "@tarojs/plugin-platform-swan": "3.5.5",
    "@tarojs/plugin-platform-tt": "3.5.5",
    "@tarojs/plugin-platform-weapp": "3.5.5",
    "@tarojs/react": "3.5.5",
    "@tarojs/router": "3.5.5",
    "@tarojs/runtime": "3.5.5",
    "@tarojs/shared": "3.5.5",
    "@tarojs/taro": "3.5.5",
    "@tarojs/taro-h5": "3.5.5",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "taro-hooks": "^2.0.0-beta-serro.3"
  },
  "devDependencies": {
    "@babel/core": "^7.8.0",
    "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
    "@taro-hooks/plugin-react": "^2.0.0-beta-serro.3",
    "@tarojs/cli": "3.5.5",
    "@tarojs/webpack5-runner": "3.5.5",
    "@types/react": "^18.0.0",
    "@types/webpack-env": "^1.13.6",
    "@typescript-eslint/eslint-plugin": "^5.20.0",
    "@typescript-eslint/parser": "^5.20.0",
    "babel-preset-taro": "3.5.5",
    "eslint": "^8.12.0",
    "eslint-config-taro": "3.5.5",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-react": "^7.8.2",
    "eslint-plugin-react-hooks": "^4.2.0",
    "react-refresh": "^0.11.0",
    "stylelint": "^14.4.0",
    "typescript": "^4.1.0",
    "webpack": "5.69.0"
  }
}

from taro-hooks.

innocces avatar innocces commented on May 10, 2024

暂时定位到的问题是:

  1. webpack5 模式下会开启预编译. 导致runtime失效. 需要关闭预编译
 compiler: {
    type: 'webpack5',
    // 依赖预编译配置
    prebundle: {
      enable: false
    }
 },
  1. 3.5 开始貌似不再开发process变量了. 但是shared会依赖这个. (这个有待解决)

  2. 模板忘记加 babel-plugin-import 这个依赖了。

模板的问题后面会一起解决. 包的问题需要再看下解决方案. 如果着急可以用 3.5 以下的版本

from taro-hooks.

innocces avatar innocces commented on May 10, 2024

记录一下相关issue

NervJS/taro#12385

from taro-hooks.

innocces avatar innocces commented on May 10, 2024

process 的 问题可以通过安装最新版来解决, taro-hooks-v2.0.0-beta-serro.5

官方模板这边快尽快更新.

以上. 若有问题再重新open

from taro-hooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.