Adam_G
Adam_G

Reputation: 7879

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')
);

Upvotes: 0

Views: 22

Answers (1)

Kid
Kid

Reputation: 1240

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


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


Upvotes: 1

Related Questions