2 April 2020

Page Title Example in react js

  • Create Components folder under src folder
  • Add PageTitleEXP1.js file and add below Code
import React, { Component } from "react";

class PageTitleEXP1 extends Component {
componentDidMount() {
document.title = "Allinoneweb";
}
render() {
return (
<div>
<h3>Page Title Example</h3>
</div>
);
}
}
export default PageTitleEXP1;
  • Open App.js file and update code as below\
import React from "react";
import ReactDOM from "react-dom";
import PageTitleEXP1 from "./components/PageTitleEXP1";

function App() {
return (
<div className="App">
<PageTitleEXP1 />
</div>
);
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Output:



No comments:

Post a Comment