MonorePo(Lerna)软件包中的一个React应用程序,导致冲突' React'包裹
我创建了:
- 可重复使用的React组件软件包,以及
- 用于测试组件的React应用程序
两者都在MonorePo(Lerna)内。 问题是组件的“反应”软件包&因为该应用指向“不同的事物”,因此使用组件内的钩子会触发此错误: “钩子只能在功能组件的主体内部调用”。
删除第二个“ React”软件包目录将对组件项目产生影响,因为它是符号链接(类似于组件项目的快捷方式)。 解决我的问题的任何想法吗? png“ alt =”在此处输入图像说明”>
I created :
- A reusable react component package, and
- A react app for testing the component
Both of them are inside a monorepo (lerna).
The problem is the "react" packages for the component & for the app are pointed to "different thing", thus using hook inside the component triggers this error:
"Hooks can only be called inside the body of a function component".
Deleting the second "react" package directory will affect to the component project because it's a symbolic linking (similar to shortcut to component project).
Any idea for resolving my problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
l使用Monorepo中的两个步骤slove React版本冲突问题。
您可以尝试。
l use that two steps slove react version conflict problem in monorepo.
You can try it.
步骤1
清除所有节点模型,DIST文件
步骤2
则步骤到root文件夹并使用-npx lenda run构建
如果您仍在面对此问题, 。根据您的要求更改TSCONFIG文件。
Step-1
Clear all node-modules, dist files
Step-2
Step to root folder and procced with - npx lerna run build
If you are still facing this issue. Change the tsconfig file based on your requirements.