我的工作是制作一个 React UI 工具包/组件库,供我们产品内部使用。在 Storybook 上开发和显示时一切正常。
在从 create-react-app 开箱即用的通用项目中测试库时,导入和实现没有 React Hooks 的组件是没问题的,但是一旦我们使用 Hooks 制作的组件 - Invalid Hook Call 错误显示:https : //reactjs.org/warnings/invalid-hook-call-warning.html
已经尝试了那里列出的所有内容(并阅读并尝试了页面上链接的 github 线程解决方案),并且该组件只是简单地使用useRef(),没有其他任何东西,所以我们知道没有违反任何规则,React 和 React-dom 版本是最新的,并且正在运行npm ls react和npm ls react-dom在项目成果react@16.10.2和react-dom@16.10.2并没有别的...所以看起来我们有多个阵营的不?
任何帮助将非常感激!!
这是 UI 套件的 package.json
{
"name": "react-ui-kit",
"version": "0.0.15",
"description": "UI Kit",
"main": "dist/index",
"module": "dist/index",
"typings": "dist/index",
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/setupTests.js"
],
"coverageReporters": [
"json-summary",
"text",
"lcov"
]
},
"scripts": {
"test": "jest --coverage",
"test:badges": "npm run test && jest-coverage-badges input './coverage/coverage-summary.json' output './badges'",
"test-update": "jest --updateSnapshot",
"lint:css": "stylelint './src/**/*.js'",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook -c .storybook -o .out",
"generate": "plop --plopfile ./.plop/plop.config.js",
"build": "webpack --mode production",
"prepare": "npm run build",
"prepublishOnly": "npm run test:badges",
"storybook-docs": "build-storybook --docs",
"todo": "leasot './src/**/*.js'",
"todo-ci": "leasot -x --reporter markdown './src/**/*.js' > TODO.md"
},
"license": "ISC",
"peerDependencies": {
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"recharts": "^1.7.1",
"styled-components": "^4.3.2",
"styled-normalize": "^8.0.6"
},
当年话下
相关分类