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

Use an additional React component within existing app

I am very new to React, but was given a dump of code without much direction. I have an existing App.js, with a number of hooks, and returns an HTML layout. How do I add a React component of react-countdown to my existing code?

I need the countdown timer in a specific <div> in my HTML, but can I just pass it in, like in the examples on this page?

import React from 'react';
import ReactDOM from 'react-dom';
import Countdown from 'react-countdown';
import App from './App';

ReactDOM.render(
  <Countdown date={Date.now() + 10000} />, //new code?
  <App />,
  document.getElementById('root')
);

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 :

Simply, you can put the Countdown component inside App like below


const App = () => {
     return (
        <>
           <CountDown />
           {OriginalCode here}
        </>
     )
}


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