You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we don't have view help like react-rails gem, how to get backend data ? pass a window.xxx global javascript variable ? or send a Ajax to backend ? or just write into static jsx file ?
And another question, the page A need Login.jsx component , another page B need Admin.jsx, if all client code has been bundle into one file, how to identify different component on different pages ? or one pages component bundle into one file, include them in rails view like this
Hi @liyaodong, the example uses this: https://github.com/rails/jquery-ujs and $.ajax. We also use on bundle for the client side application, and check if a div id is on a page, before rendering the react component. It's also possible to put global data on the page. I've often used the https://github.com/gazay/gon for doing that.
If we don't have view help like react-rails gem, how to get backend data ? pass a window.xxx global javascript variable ? or send a Ajax to backend ? or just write into static jsx file ?
And another question, the page A need Login.jsx component , another page B need Admin.jsx, if all client code has been bundle into one file, how to identify different component on different pages ? or one pages component bundle into one file, include them in rails view like this
dev mode
<script src="http://localhost:8080/assets/<%= controller_name + '_' + action_name%>-bundle.self.js"></script>
What is the best practice, please give your opinions, Thank you all !
The text was updated successfully, but these errors were encountered: