Creating React Components in PHP and then Rendering in the Client
I am trying to use React to simplify the way I create a UI for an application I am writing. I have a good proof of concept working on a single HTML page, but I need to split the JS into separate modules to make it easier to maintain.
I know how to structure an application if every piece of the puzzle is known at build time. Something like this: https://github.com/jordwalke/reactapp . However, the UI will be dynamically generated in PHP, embedding the various components that I want to pass into the application.
My initial thought of dumping the generated code into a script tag and having Javascript found that it was driving me into a terrible hell of a hell.
My main question:
How do I pass something like
<panel><group><field /></group></panel>
to the application so that I can call itReact.render()
?
source to share