2

What is the neatest way to update Dom content of a rendered component outside of react environment.

Example: I have a reactjs app fully rendered into browser and then I have separate js file that I want to use for experiment purpose to update content of the already rendered Dom. Problem is react itself updates it's component back to its original state.

Arun Kumar
  • 163
  • 8
  • 1
    Sorry me to be boring, but reactJS uses virtual DOM after sync with the real DOM updates and it (react) doesn't care about external changes.. If you try to explain the TRUE reason why you have to do that, maybe I may help you – Max Feb 02 '19 at 00:50
  • True reason is adding small changes for few hours for few users to see how they reapond without adding those changes in codebase and deploying the changes on the fly – Arun Kumar Feb 02 '19 at 00:52
  • Okay, I see. A/B testing. Then I would suggest you more professional way to make AB testing with react.. Just googled this article looks good to me https://pillow.codes/how-to-quickly-set-up-a-b-testing-for-react-websites-dcb321fcd1f – Max Feb 02 '19 at 00:54
  • See this requires updating your codebase with all the variants.I don't want to have test code in my codebase – Arun Kumar Feb 02 '19 at 00:57
  • Yep, I understand that. But this is a PROPER way to do that and I believe the ONLY one – Max Feb 02 '19 at 00:58
  • Some thoughts about AB. The thing is AB testing was never as easy as changing few line of DOM, it's all about collecting data, analyzing users behavior between 2 not different view/flows and believe it or not, but it's better spend some hours and configure AB testing correctly and be happy. I don't know the exactly what you are trying to test, but yeah, do it correctly. Is this some minor visual stuff? – Max Feb 02 '19 at 01:03
  • `Problem is react itself updates it's component back to its original state` - that's not a problem... that's how and what it was designed to do... Perhaps consider another library or framework... – SakoBu Feb 02 '19 at 01:32
  • Need to update a small part of a web page provided by a huge and bureaucratic company who has its own framework built on React and is in total possession of development environment? – JN01 Nov 15 '21 at 07:44

0 Answers0