Call Javascript function from react componentsCall external Javascript function from react componentsHow do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?var functionName = function() vs function functionName() Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

How can "mimic phobia" be cured or prevented?

How to align and center standalone amsmath equations?

Translation of Scottish 16th century church stained glass

Does the Mind Blank spell prevent the target from being frightened?

Is it possible to have a strip of cold climate in the middle of a planet?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

Have I saved too much for retirement so far?

Drawing a topological "handle" with Tikz

Why does Async/Await work properly when the loop is inside the async function and not the other way around?

Customize circled numbers

How to decide convergence of Integrals

Is a model fitted to data or is data fitted to a model?

Can I sign legal documents with a smiley face?

Varistor? Purpose and principle

Bob has never been a M before

Is it improper etiquette to ask your opponent what his/her rating is before the game?

List of people who lose a child in תנ"ך

Create all possible words using a set or letters

Should I stop contributing to retirement accounts?

Is it possible to use .desktop files to open local pdf files on specific pages with a browser?

Sampling Theorem and reconstruction

Divine apple island

What does this horizontal bar at the first measure mean?

Flux received by a negative charge



Call Javascript function from react components


Call external Javascript function from react componentsHow do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?var functionName = function() vs function functionName() Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?













0















I have one question because I'm not sure if that possible. I have ReactJS project that included some javascript functions.



I found solution to call javascript function from react components with window object but is it possible to call function from reactcomponents in javascript script?



For example I have definied function in React component. Is it possible to call that function in javascript?



Thank you.










share|improve this question



















  • 1





    is it possible to call function from reactcomponents in javascript script? Yes. That is completely possible. Create a module and import necessary component / function and call it

    – Rajesh
    Mar 7 at 9:03






  • 1





    Of course, React is just a library for javascript. You can call builtin javascript function as well as user-defined global javascript function from your react code

    – sriharsha_bhat
    Mar 7 at 9:04











  • any example or something? I'm working first time with this combination so please send me some example.

    – Devmasta
    Mar 7 at 9:04






  • 1





    StackOverflow is not a code-writing service. Please read through the Help Center, in particular How do I ask a good question?

    – Andreas
    Mar 7 at 9:08















0















I have one question because I'm not sure if that possible. I have ReactJS project that included some javascript functions.



I found solution to call javascript function from react components with window object but is it possible to call function from reactcomponents in javascript script?



For example I have definied function in React component. Is it possible to call that function in javascript?



Thank you.










share|improve this question



















  • 1





    is it possible to call function from reactcomponents in javascript script? Yes. That is completely possible. Create a module and import necessary component / function and call it

    – Rajesh
    Mar 7 at 9:03






  • 1





    Of course, React is just a library for javascript. You can call builtin javascript function as well as user-defined global javascript function from your react code

    – sriharsha_bhat
    Mar 7 at 9:04











  • any example or something? I'm working first time with this combination so please send me some example.

    – Devmasta
    Mar 7 at 9:04






  • 1





    StackOverflow is not a code-writing service. Please read through the Help Center, in particular How do I ask a good question?

    – Andreas
    Mar 7 at 9:08













0












0








0








I have one question because I'm not sure if that possible. I have ReactJS project that included some javascript functions.



I found solution to call javascript function from react components with window object but is it possible to call function from reactcomponents in javascript script?



For example I have definied function in React component. Is it possible to call that function in javascript?



Thank you.










share|improve this question
















I have one question because I'm not sure if that possible. I have ReactJS project that included some javascript functions.



I found solution to call javascript function from react components with window object but is it possible to call function from reactcomponents in javascript script?



For example I have definied function in React component. Is it possible to call that function in javascript?



Thank you.







javascript reactjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 9:20







Devmasta

















asked Mar 7 at 9:02









DevmastaDevmasta

143619




143619







  • 1





    is it possible to call function from reactcomponents in javascript script? Yes. That is completely possible. Create a module and import necessary component / function and call it

    – Rajesh
    Mar 7 at 9:03






  • 1





    Of course, React is just a library for javascript. You can call builtin javascript function as well as user-defined global javascript function from your react code

    – sriharsha_bhat
    Mar 7 at 9:04











  • any example or something? I'm working first time with this combination so please send me some example.

    – Devmasta
    Mar 7 at 9:04






  • 1





    StackOverflow is not a code-writing service. Please read through the Help Center, in particular How do I ask a good question?

    – Andreas
    Mar 7 at 9:08












  • 1





    is it possible to call function from reactcomponents in javascript script? Yes. That is completely possible. Create a module and import necessary component / function and call it

    – Rajesh
    Mar 7 at 9:03






  • 1





    Of course, React is just a library for javascript. You can call builtin javascript function as well as user-defined global javascript function from your react code

    – sriharsha_bhat
    Mar 7 at 9:04











  • any example or something? I'm working first time with this combination so please send me some example.

    – Devmasta
    Mar 7 at 9:04






  • 1





    StackOverflow is not a code-writing service. Please read through the Help Center, in particular How do I ask a good question?

    – Andreas
    Mar 7 at 9:08







1




1





is it possible to call function from reactcomponents in javascript script? Yes. That is completely possible. Create a module and import necessary component / function and call it

– Rajesh
Mar 7 at 9:03





is it possible to call function from reactcomponents in javascript script? Yes. That is completely possible. Create a module and import necessary component / function and call it

– Rajesh
Mar 7 at 9:03




1




1





Of course, React is just a library for javascript. You can call builtin javascript function as well as user-defined global javascript function from your react code

– sriharsha_bhat
Mar 7 at 9:04





Of course, React is just a library for javascript. You can call builtin javascript function as well as user-defined global javascript function from your react code

– sriharsha_bhat
Mar 7 at 9:04













any example or something? I'm working first time with this combination so please send me some example.

– Devmasta
Mar 7 at 9:04





any example or something? I'm working first time with this combination so please send me some example.

– Devmasta
Mar 7 at 9:04




1




1





StackOverflow is not a code-writing service. Please read through the Help Center, in particular How do I ask a good question?

– Andreas
Mar 7 at 9:08





StackOverflow is not a code-writing service. Please read through the Help Center, in particular How do I ask a good question?

– Andreas
Mar 7 at 9:08












1 Answer
1






active

oldest

votes


















3














Yes it is.






const App = () => <div>Hello world externalFunction() </div>;

ReactDOM.render( <App/>, document.querySelector( '#root' ) );

<script>
// Imagine this is an external source
function externalFunction()
return Math.round( Math.random() * 100 );

</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

<div id="root"></div>





Resources



  • Some further readings on how to embed other script files
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script

  • Also a really interesting article on what JS is or rather how it is working on a website
    https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55039774%2fcall-javascript-function-from-react-components%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Yes it is.






    const App = () => <div>Hello world externalFunction() </div>;

    ReactDOM.render( <App/>, document.querySelector( '#root' ) );

    <script>
    // Imagine this is an external source
    function externalFunction()
    return Math.round( Math.random() * 100 );

    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

    <div id="root"></div>





    Resources



    • Some further readings on how to embed other script files
      https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script

    • Also a really interesting article on what JS is or rather how it is working on a website
      https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript





    share|improve this answer



























      3














      Yes it is.






      const App = () => <div>Hello world externalFunction() </div>;

      ReactDOM.render( <App/>, document.querySelector( '#root' ) );

      <script>
      // Imagine this is an external source
      function externalFunction()
      return Math.round( Math.random() * 100 );

      </script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

      <div id="root"></div>





      Resources



      • Some further readings on how to embed other script files
        https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script

      • Also a really interesting article on what JS is or rather how it is working on a website
        https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript





      share|improve this answer

























        3












        3








        3







        Yes it is.






        const App = () => <div>Hello world externalFunction() </div>;

        ReactDOM.render( <App/>, document.querySelector( '#root' ) );

        <script>
        // Imagine this is an external source
        function externalFunction()
        return Math.round( Math.random() * 100 );

        </script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

        <div id="root"></div>





        Resources



        • Some further readings on how to embed other script files
          https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script

        • Also a really interesting article on what JS is or rather how it is working on a website
          https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript





        share|improve this answer













        Yes it is.






        const App = () => <div>Hello world externalFunction() </div>;

        ReactDOM.render( <App/>, document.querySelector( '#root' ) );

        <script>
        // Imagine this is an external source
        function externalFunction()
        return Math.round( Math.random() * 100 );

        </script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

        <div id="root"></div>





        Resources



        • Some further readings on how to embed other script files
          https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script

        • Also a really interesting article on what JS is or rather how it is working on a website
          https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript





        const App = () => <div>Hello world externalFunction() </div>;

        ReactDOM.render( <App/>, document.querySelector( '#root' ) );

        <script>
        // Imagine this is an external source
        function externalFunction()
        return Math.round( Math.random() * 100 );

        </script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

        <div id="root"></div>





        const App = () => <div>Hello world externalFunction() </div>;

        ReactDOM.render( <App/>, document.querySelector( '#root' ) );

        <script>
        // Imagine this is an external source
        function externalFunction()
        return Math.round( Math.random() * 100 );

        </script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

        <div id="root"></div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 9:08









        lumiolumio

        4,86522238




        4,86522238





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55039774%2fcall-javascript-function-from-react-components%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved