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
Post a Comment