rockiger / reactpress

Plugin that lets you easily create, build and deploy React apps into your existing WordPress sites.
https://rockiger.com/en/reactpress/
GNU General Public License v2.0
50 stars 6 forks source link

Create documentation (videos) #11

Open rockiger opened 2 years ago

rockiger commented 2 years ago
TonyGravagno commented 1 year ago

Whether for written docs or video, I'd like to see more of a "comfort zone" established in documentation for what a finished result would look like, and the handshaking with WP.

For example: In a site let's say there are two WP page-post-types that are linked from the home page. On one page is a tiny React app with nothing more than a MUI TextField and Button. "Enter your favorite color / Submit". On another page is a similarly tiny React app that retrieves all submissions and renders them in a loop on ListItemText. The apps are embedded in the pages via ReactPress shortcodes.

As you see, my challenge isn't really with WP or React, it's understanding what options are available after we have deployed a React app into a WP page with ReactPress. I suppose I'll learn when I read the code but I think it would help to have docs too.

Thanks!

rockiger commented 1 year ago

I will keep that in mind when I update the docs.

rockiger commented 1 year ago

@TonyGravagno I started work on a documentation page that answers your questions. It is far from finished, but maybe you want to have a look already.

TonyGravagno commented 1 year ago

Thank you Very much, Marco! That is a great start. Your page on routing is also very helpful, thanks.

Preface - I'm not looking for answers to specific questions here. I'm documenting the kinds of questions that I think of when I read that new doc page and anything else related to this plugin. And I hope the new docs/vids can answer all questions like these for ReactPress users.

All of my questions revolve around: At what point in the lifecycle does ReactPress stop providing additional value, requiring the React app to do things on its own? I believe the answer is that ReactPress embeds a React app in the content area of a page, and that's where it stops. Would that be correct?

Examples:

I think the answer to all of this is that ReactPress really does "draw the line" at inserting the React app into the page, and everything else is up to the developer. We use CRA, npm/yarn install, and do our imports, we integrate with WP through the REST API, and the only app integration that ReactPress provides is the static reactPress global on initial entry.

In my original question I asked about Context. Now I'm thinking we can useContext, @wordpress/persistence, or whatever other mechanism we want.

Finally, sorry if I missed this in existing info: Is there a hook or other mechanism that would allow us to add properties to reactPress, or to add another custom global that has our own initial statebag? I'm guessing we should hook the page load ourselves and enqueue a script - I just don't know if ReactPress already has a defined way of doing this.

Summary : I'm hoping docs and vids clarify what ReactPress does and does not enqueue into the page that is hosting an app.

Thanks again!