Yarn 将 React 组件库链接到应用程序会导致“无效的 Hook 调用”错误(多个 React 实例)

Shm*_*opy 6 npm reactjs

我有一个由 create-react-app 和 React 组件库组成的 React 应用程序。我正在尝试将组件库链接到应用程序以在本地测试组件。当我尝试使用库中的组件时,出现错误:

\n
Uncaught Error: 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:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\n
Run Code Online (Sandbox Code Playgroud)\n

我在互联网上(主要是这个问题)搜索了这个问题的解决方案,并找到了一些关于链接应用程序的 React 依赖项并在组件库中使用链接的 React 的建议。这似乎对几个人都有效,所以我通过执行以下操作来完成此操作:

\n

在应用程序中:

\n
cd node_modules/react\nyarn link\n
Run Code Online (Sandbox Code Playgroud)\n

在图书馆:

\n
yarn link react\nyarn link\n
Run Code Online (Sandbox Code Playgroud)\n

返回应用程序:

\n
yarn link {library_name}\nyarn start\n
Run Code Online (Sandbox Code Playgroud)\n

然而,这会导致完全相同的错误。我已经重复了上述步骤react-dom以及react-bootstrap这些是两者之间的其他重叠反应模块,但仍然得到相同的结果。

\n

我也尝试过以这种方式从组件库链接:npm link {PATH_TO_APP}/node_modules/react得到相同的结果。

\n

alias由于使用,我无法使用 webpack配置create-react-app配置。

\n

这是一些附加信息:

\n

应用程序依赖项:

\n
"dependencies": {\n    "@types/lodash": "^4.14.178",\n    "@types/react": "^17.0.37",\n    "@types/react-beautiful-dnd": "^13.1.2",\n    "@types/react-dom": "^17.0.6",\n    "@types/react-router-dom": "^5.3.2",\n    "bootstrap": "5.1.3",\n    "classnames": "^2.3.1",\n    "lodash": "^4.17.21",\n    "react": "^17.0.2",\n    "react-beautiful-dnd": "^13.1.0",\n    "react-bootstrap": "2.1.0",\n    "react-dom": "^17.0.2",\n    "react-helmet-async": "^1.2.2",\n    "react-router-dom": "^5.0.1",\n    "react-scripts": "^5.0.0",\n    "sass": "^1.49.0",\n    "typescript": "^4.5.5"\n},\n"devDependencies": {\n    "husky": "^7.0.4",\n    "lint-staged": "^12.3.1"\n},\n
Run Code Online (Sandbox Code Playgroud)\n

库依赖项:

\n
"peerDependencies": {\n    "react": "^17.0.2",\n    "react-bootstrap": "2.1.0",\n    "react-dom": "^17.0.2"\n},\n"devDependencies": {\n    "@babel/core": "^7.16.0",\n    "@storybook/addon-actions": "^6.4.7",\n    "@storybook/addon-docs": "^6.4.7",\n    "@storybook/addon-essentials": "^6.4.7",\n    "@storybook/addon-links": "^6.4.7",\n    "@storybook/builder-webpack5": "^6.4.7",\n    "@storybook/components": "^6.4.7",\n    "@storybook/core-events": "^6.4.7",\n    "@storybook/manager-webpack5": "^6.4.7",\n    "@storybook/react": "^6.4.7",\n    "@storybook/theming": "^6.4.7",\n    "@svgr/cli": "^6.0.0",\n    "babel-loader": "^8.2.3",\n    "husky": ">=6",\n    "lint-staged": ">=10",\n    "npm-run-all": "^4.1.5",\n    "react": "^17.0.2",\n    "react-bootstrap": "2.1.0",\n    "react-dom": "^17.0.2",\n    "ts-loader": "^9.2.6",\n    "typescript": "^4.4.4",\n    "webpack": "^5.60.0",\n    "webpack-cli": "^4.9.1"\n},\n"dependencies": {}\n
Run Code Online (Sandbox Code Playgroud)\n

这是结果npm ls -g --depth=0 --link=true

\n
{PATH_TO_NODE}/v16.13.2/lib\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 react-bootstrap@2.1.0 -> {PATH_TO_APP}/node_modules/react-bootstrap\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 react-dom@17.0.2 -> {PATH_TO_APP}/node_modules/react-dom\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 -> {PATH_TO_APP}/node_modules/react\n
Run Code Online (Sandbox Code Playgroud)\n

这是结果npm ls react组件库中的结果。

\n
\xe2\x9e\x9c  {COMPONENT_LIBRARY} git:(first-design-system-component) \xe2\x9c\x97 npm ls react \n{COMPONENT_LIBRARY}@1.0.5 {PATH_TOCOMPONENT_LIBRARY}\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-aria/ssr@3.1.0 extraneous\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @restart/hooks@0.4.5 extraneous\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @restart/ui@0.2.6 extraneous\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-actions@6.4.7\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addons@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/api@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-inspector@5.1.1\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-docs@6.4.7\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @mdx-js/react@1.6.22\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/builder-webpack4@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/core@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/core-client@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/core-server@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/manager-webpack4@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/preview-web@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/source-loader@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/store@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-element-to-jsx-string@14.3.4\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-essentials@6.4.7\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-backgrounds@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-controls@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-measure@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-outline@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-toolbars@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-viewport@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/addon-links@6.4.7\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/router@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-router-dom@6.0.2\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-router@6.0.2\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/builder-webpack5@6.4.7\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/client-api@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/core-common@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/components@6.4.7\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac markdown-to-jsx@7.1.3\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-colorful@5.5.0\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-popper-tooltip@3.1.1\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-popper@2.2.5\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-syntax-highlighter@13.5.3\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-textarea-autosize@8.3.3\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac use-composed-ref@1.1.0\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\xac use-latest@1.2.0\n\xe2\x94\x82 \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\xac use-isomorphic-layout-effect@1.1.1\n\xe2\x94\x82 \xe2\x94\x82     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/manager-webpack5@6.4.7\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/core-client@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/ui@6.4.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac downshift@6.1.7\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-draggable@4.4.4\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-helmet-async@1.1.2\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/react@6.4.7\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @storybook/theming@6.4.7\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @emotion/core@10.1.1\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @emotion/styled@10.0.27\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @emotion/styled-base@10.0.31\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac emotion-theming@10.0.27\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac prop-types-extra@1.1.1 extraneous\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-bootstrap@2.1.0 -> {PATH_TO_APP}/node_modules/react-bootstrap\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @restart/hooks@0.4.5\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @restart/ui@0.2.6\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @react-aria/ssr@3.1.0\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac prop-types-extra@1.1.1\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-transition-group@4.4.2\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\xac uncontrollable@7.2.1\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac react-transition-group@4.4.2 extraneous\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 react@17.0.2 -> {PATH_TO_APP}/node_modules/react\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\xac uncontrollable@7.2.1 extraneous\n  \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 react@17.0.2 deduped -> {PATH_TO_APP}/node_modules/react\n
Run Code Online (Sandbox Code Playgroud)\n

小智 2

我建议尝试链接react-dom,就像你对react所做的那样,如果你还没有这样做的话。