1import React, { useEffect } from 'react'
2import ReactDOM from 'react-dom'
3
4const App = () => {
5 // This effect runs once, after the first render
6 useEffect(() => {
7 document.title = "This is a title"
8 }, [])
9
10 return <h1>Hello, World!</h1>
11};
12
13ReactDOM.render(
14 <App />,
15 document.getElementById('root')
16);
1import React from 'react'
2import ReactDOM from 'react-dom'
3
4
5class Doc extends React.Component{
6 componentDidMount(){
7 document.title = "dfsdfsdfsd"
8 }
9
10 render(){
11 return(
12 <b> test </b>
13 )
14 }
15}
16
17ReactDOM.render(
18 <Doc />,
19 document.getElementById('container')
20);