gpt4 book ai didi

javascript - 是否可以在同一页面上运行两个不同版本的 ReactJS?

转载 作者:行者123 更新时间:2023-11-29 10:08:16 24 4
gpt4 key购买 nike

大家好,我想知道是否可以在同一页面上运行两个版本的 ReactJS,类似于 jQuery.noConflict()

通过一些研究,我发现了两个有趣的事情:

Two Reacts Won’t Be Friends

While I’m happy that everybody seems to be converging on NPM in 2015 and NPM wants developers to use it for managing front-end dependencies, it still has rough edges. The biggest problem with using NPM for front-end dependencies is that if two packages specify a library like React as a dependency, they might get two separate copies of React. Even worse, they might get different versions of it. This works fine for something like Node, but not for browser libraries that want to mess with the same global mutable DOM! NPM tried to solve this with peerDependencies but all hell broke loose and they’re backing out.

https://medium.com/@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375#.hfx35f6hl

github 上的一个问题:https://github.com/facebook/react/issues/1939

但是我不清楚我们如何包装和交付我们的 ReactJS 小部件,以便它们可以在使用其他版本的 ReactJS 的页面上无冲突地运行。

谢谢

最佳答案

However is not clear for me how we could wrap & delivery our ReactJS widgets in order they could run without conflicts on a page using other version of ReactJS.

您可以使用 Browserifyreactify加载您的 JS 和 ReactJS 版本,而不会与页面上可能加载的另一个 ReactJS 版本发生冲突。

此处提供更多信息:

关于javascript - 是否可以在同一页面上运行两个不同版本的 ReactJS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38783430/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com