node.js - How to use an ejs variable inside a react render function? -
i'm passing variable abcd
index.ejs in turn calls react js file render index.ejs page. i've been able access <%= abcd %>
inside index.ejs not inside render function of react. can me out?
thanks
i faced same problem index.html file, filled react component, , resolved this:
in index.html
<script> window.abcd = '<%- abcd %>'; </script>
in react component
render: function(){ return( <div> <p> {window.abcd} </p> </div> ); }
this worked me, if has cleaner proposition, i'm in!
Comments
Post a Comment