DeloitteAU / react-habitat

⚛️ 🛅 A React DOM Bootstrapper designed to harmonise a hybrid 'CMS + React' application.
Other
262 stars 42 forks source link

CONT issue #14 Questions (it was closed too early) #19

Closed edbras closed 7 years ago

edbras commented 7 years ago

Thanks for your answers.

Its important that your javascript is included at the end of the page (just before ) as it will only parse HTML rendered before it. How does this look if it concerns a html snippet that is downloaded from the backend API? In case of a SPA (Single Page App), it happens that you replace/add/remove html parts on a screen. I like to parse a html part that will contain a root div and many nested html elements. How should I parse this such that habitat will add the required components?

In pseude-code:

htmlSnippet = retrieveFromBackend();
parseWithHabitat(htmlSnippet); (??)
edbras commented 7 years ago

Any update on this issue ? Thanks, Ed

jennasalau commented 7 years ago

Hi Ed,

Thanks for your follow up question. For future reference, when a Github issue is closed. You can actually still comment on it and it can be reopened if need be. This helps keep the conversation in one place which benefits 3rd part readers.

With regards to your pseude-code. That is not how React Habitat works. React Habitat is never given HTML to parse. Instead it reads the HTML from the page it is included on. The concept is nothing new and similar to how a jQuery selector might work. I suggest reaching out to your local developer network to help explain this framework, its examples and my original answers to you. I also encourage you to look through the source code to see how it works.

Thanks, Jenna

edbras commented 7 years ago

Thanks for the update. I will further look at your code on how to use it, like the method "parseContainer" you did send before.