reactjs - Global scope variable with React JS? -


in code, create function initializes tag of reactdom.render() function :

var initialisertag;  initialisertag = function(tag){   reactdom.render(<myapp />, document.getelementbyid(tag)); }  export default initialisertag; 

then bundle react code webpack , put bundle.js file @ end of page:

{% block javascripts %}{{ parent() }}      <!-- todo        call initialisertag('mytag') here      -->         <script src="{{ asset('bundles/app/bundle.js') }}"></script>                                 {% endblock %} 

how can call initialisertag() function outside bundle?

you use expose-loader exposing modules global object.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -