企业如何优化其营销网站的排名和展厅设计?
摘要:企业营销网站建设公司排名,企业文化展厅设计,网站打开速度慢wordpress,曲阜做网站的公司使用 dumi 开发 React 组件库时,为避免每次修改都发布到 npm,需要在本地
企业营销网站建设公司排名,企业文化展厅设计,网站打开速度慢wordpress,曲阜做网站的公司使用 dumi 开发 React 组件库时#xff0c;为避免每次修改都发布到 npm#xff0c;需要在本地的测试项目中使用 npm link 为组件库建立软连接#xff0c;方便本地调试。 结果在本地测试项目使用 $ npm link 组件库 后#xff0c;使用内部组件确报错#xff1a; react.dev… 使用 dumi 开发 React 组件库时为避免每次修改都发布到 npm需要在本地的测试项目中使用 npm link 为组件库建立软连接方便本地调试。 结果在本地测试项目使用 $ npm link 组件库 后使用内部组件确报错 react.development.js:209 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.报错信息中提供了三种可能的原因针对这三个可能原因逐一检查: React Hooks 是 React 16.8.0 版本中引入的先检查 react 和 react-dom 的版本。发现是高于 16.8.0 的支持 React Hook。排除 检查是否违背了调用 hook 的规则。然而组件中并未使用 hook但是依赖的第三方库使用了 hook并且使用方式是正确的排除 检查项目中是否存在多个不同版本的 react 。发现测试项目和组件库中都存在 react 依赖但是组件库中的 package.json 中已经将 react 和 react-dom 都添加到了 peerDependencies 属性中。待定 极有可能是因为第三条导致了问题继续查阅文档官网 在此处 给出过可能的原因。 This problem can also come up when you use npm link or an equivalent. In that case, your bundler might “see” two Reacts — one in application folder and one in your library folder. Assuming myapp and mylib are sibling folders, one possible fix is to run npm link …/myapp/node_modules/react from mylib. This should make the library use the application’s React copy. 已经基本确定是由于 npm link 引发了问题猜测使用 npm link 时不会忽略 package.json 中的 peerDependencies 选项而组件库中 react 版本依赖都存放在这个选项内。 解决方案 例如组件库项目根路径/Users/xxx/Desktop/design、测试项目根路径/Users/xxx/Desktop/testlink。 在 测试项目 中软链接 组件库项目 中安装的 react 版本即可如果还未解决再将 react-dom 也进行软链接到测试项目。 # 1、进入测试项目
$ cd /Users/xxx/Desktop/testlink# 2、软链接组件库中安装的 react 版本
$ npm link /Users/xxx/Desktop/design/node_modules/react
# 备用如果还是报错可在链接 react-dom但是一般不需要link react 基本也就解决了。
