score:0

import * as React from 'react'

function App(){
    const [name, setName] = React.useState('Henok')

    const changeName = () => setName('Rahel')

    React.useEffect(() => {
       setTimeout(() => {
          changeName()
       }, 2000);
    }, [])

    return <Greeting name={name} />
} 


function Greeting(props){     
    return <h1>{props.name}</h1>;
}  


ReactDOM.render(<App />, document.getElementById('root'));

Related Query

More Query from same tag