Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I need ReactDOM.render to render each time its called

I am working on an app that will be going inside another web application. I need ReactDOM.render to re-render my app each time the focus function is called. Right now it only renders it once but then each time after that it does not re-render it. Focus is called each time a user enters my app, so I need react to re-render each time to stay updated.

focus: function (freshApi, freshState) {
      // show main content
      // elAddin.className = elAddin.className.replace('hidden', '').trim();
      console.log('test');
      var elAddin = document.getElementById('customFuelTracker');
      ReactDOM.render(<App geotabApi={freshApi} geotabState={freshState} appName={'customFuelTracker'} />, elAddin);    
    },

I’ve tried erasing the innerHTML of the container on exit, but that still requires a page refresh to reload react.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try unmountComponentAtNode

focus: function (freshApi, freshState) {
      // show main content
      // elAddin.className = elAddin.className.replace('hidden', '').trim();
      console.log('test');
      var elAddin = document.getElementById('customFuelTracker')
      ReactDOM.unmountComponentAtNode(elAdmin)
      ReactDOM.render(<App geotabApi={freshApi} geotabState={freshState} appName={'customFuelTracker'} />, elAddin);    
    },
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading