最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - is it possible to run two different versions of ReactJS on the same page? - Stack Overflow

programmeradmin0浏览0评论

Hello everyone I am wondering if is possible to run two version of ReactJS on the same page , something similar to jQuery.noConflict().

With a bit of research i have found two interesting things :

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.

/@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375#.hfx35f6hl

And an issue on github:

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 .

thanks

Hello everyone I am wondering if is possible to run two version of ReactJS on the same page , something similar to jQuery.noConflict().

With a bit of research i have found two interesting things :

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./@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375#.hfx35f6hl

And an issue on github: https://github./facebook/react/issues/1939

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 .

thanks

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Aug 5, 2016 at 7:20 ivanivan 5702 gold badges5 silver badges12 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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.

You can use Browserify with reactify to load your JS and version of ReactJS without conflicting with another ReactJS version that may be loaded on the page.

More information is available here:

  • Embeddable JavaScript widget with React
发布评论

评论列表(0)

  1. 暂无评论