Why not use React.Component.prototype.$store = store in React like Vue

Global libraries are often added to VUE.prototype in VUE. Why few people use them in react? I think this is much more convenient than using context.

Mar.30,2021

first of all, you can write this in react. For example:

React.Component.prototype.$store = $store;

is available, but this is not common! Why? Listen to me blow for you.

react is more pure , functional .

mounting your method to prototype is a very impure operation.

you can take a look at redux, the popular data management library in react ecology, which is implemented through react-redux with higher-order functions with the help of context.
you can see a lot of these operations in react , in contrast, you will see that there are a lot of operations in vue that attach objects and methods to prototype.

how many HOC models have you seen in vue?


first of all, I don't know how to react, after watching it three or four times. I find it difficult to get started, or maybe it's because of my skill. If you look at what you said, ah, I think it is mainly because of the writing method. The functional programming of react is basically written as class an extends b., class Point = Point.prototype.constructor.. It's pure nonsense, and I know if it's right, I also wrote it to ask other great gods whether I can add things to


Why not import? this addition will make others think that it is brought with it, but a refactoring or modification will wonder why


react does not recommend extending


key how to use it

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37e86-2c0d7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37e86-2c0d7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?