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

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

html - How to custom Bootstrap grid height? -