Call normal javascript function from another document in a react component function

noa-dev

I am trying to call a normal javascript function inside of a react component function.

The script tags are nested in the footer as following :

<script src="NORMAL JAVASCRIPT STUFF"></script> // function test(){};
<script src="REACT STUFF"></script>

So the javascript file with the function that I need is being read earlier. So the function should be available in the whole document.

Now when I try to call the function within some react component function like that:

....,
someFunction: function(){
test();
},...

I get Uncaught ReferenceError: test is not defined

Does anyone know how to access normal functions inside of react?

Michael Parker

That function would belong to the window object, so you would need to call window.test(); instead.

See here:

https://jsfiddle.net/7dzdp9rw/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to call a function from another component in react

From Dev

How to call a function from a component in another component?

From Dev

Call React Component Function from onclick in dangerouslySetInnerHTML

From Dev

How to call a function in other function from html document - JavaScript.

From Dev

How to call a function in other function from html document - JavaScript.

From Dev

Call external Javascript function from react components

From Dev

How do I call a function from another component

From Dev

JavaScript – Call a function of the prototype from another prototype function?

From Dev

React call component's method from nested function in render method

From Dev

Calling function from another component

From Dev

Call react component from javascript

From Dev

Another way to call function javascript

From Dev

How to call a function within another function in javascript

From Dev

Javascript function call with another function as parameter

From Dev

How to call a function within another function in javascript

From Dev

Cannot call a function inside another function javascript

From Dev

How to call a function that is inside another function javascript

From Java

Call a function from another file?

From Dev

Call function from another script

From Dev

Call a function from another thread

From Dev

Call a function from an another class

From Dev

Call an anonymous function from another

From Dev

Call an async function in an normal function

From Dev

jquery + php - Call Function From Another Javascript Wrapper

From Dev

Aframe - call aframe function from another javascript file

From Dev

Call function from another function Mysql

From Dev

Call a __init__ function from another function

From Dev

how to call a function from another function in Jquery

From Dev

Call function from another function in jQuery OOP

Related Related

  1. 1

    how to call a function from another component in react

  2. 2

    How to call a function from a component in another component?

  3. 3

    Call React Component Function from onclick in dangerouslySetInnerHTML

  4. 4

    How to call a function in other function from html document - JavaScript.

  5. 5

    How to call a function in other function from html document - JavaScript.

  6. 6

    Call external Javascript function from react components

  7. 7

    How do I call a function from another component

  8. 8

    JavaScript – Call a function of the prototype from another prototype function?

  9. 9

    React call component's method from nested function in render method

  10. 10

    Calling function from another component

  11. 11

    Call react component from javascript

  12. 12

    Another way to call function javascript

  13. 13

    How to call a function within another function in javascript

  14. 14

    Javascript function call with another function as parameter

  15. 15

    How to call a function within another function in javascript

  16. 16

    Cannot call a function inside another function javascript

  17. 17

    How to call a function that is inside another function javascript

  18. 18

    Call a function from another file?

  19. 19

    Call function from another script

  20. 20

    Call a function from another thread

  21. 21

    Call a function from an another class

  22. 22

    Call an anonymous function from another

  23. 23

    Call an async function in an normal function

  24. 24

    jquery + php - Call Function From Another Javascript Wrapper

  25. 25

    Aframe - call aframe function from another javascript file

  26. 26

    Call function from another function Mysql

  27. 27

    Call a __init__ function from another function

  28. 28

    how to call a function from another function in Jquery

  29. 29

    Call function from another function in jQuery OOP

HotTag

Archive