react change title of page code example
Example 1: react set title of page
import React, { useEffect } from 'react'
import ReactDOM from 'react-dom'
const App = () => {
useEffect(() => {
document.title = "This is a title"
}, [])
return <h1>Hello, World!</h1>
};
ReactDOM.render(
<App />,
document.getElementById('root')
);
Example 2: change title react
import React from 'react'
import ReactDOM from 'react-dom'
class Doc extends React.Component{
componentDidMount(){
document.title = "dfsdfsdfsd"
}
render(){
return(
<b> test </b>
)
}
}
ReactDOM.render(
<Doc />,
document.getElementById('container')
);