Can react define a global method like vue?

for example, a function that determines whether it is an object

export const isObject = function (ob) {
  return Object.prototype.toString.call(ob)  ===  "[object Object]"
}

the function import is required for every reference, which is troublesome
but you can bind it to the prototype of the vue instance in vue, such as vue.prototype.isObject = func

.

is there a similar method for react?

Mar.10,2021

this has nothing to do with the framework. In the browser environment, directly window.XXX is fine.


    The idea of
  • react is componentization or modularization
  • should be
  • that does not support custom global variables.

Yes.
but in a different way.
higher-level components can define global methods.
or content can also provide global methods.

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-1b3faf6-2c4cc.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-1b3faf6-2c4cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?