Using React-Helmet in React.js

What is React-Helmet?

Using React-Helmet in React.js

npx create-react-app frontend
npm install react-helmet
npm start
npm install react-router-dom
import React from "react";function Dashboard(){return(<div className="dashboard"><h1>This is Dashboard</h1></div>);}export default Dashboard;
import Dashboard from './components/Dashboard';import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";function App() {return (<div className=""><Router><Routes><Route  path="/" element={ <Dashboard />} /></Routes></Router></div>);}export default App;
import React from "react";import {Helmet} from "react-helmet";function About(){return(<div className="about"><Helmet><meta charSet="utf-8" /><title>About</title></Helmet><h1>This is about page</h1></div>);}export default About;
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";import Dashboard from './components/Dashboard';import About from "./components/About";function App() {return (<div className=""><Router><Routes><Route  path="/" element={ <Dashboard />} /><Route  path="/about" element={ <About />} /></Routes></Router></div>);}export default App;

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Musab Abbasi

Musab Abbasi

88 Followers

Computer Science Graduate with MERN stack website development expertise.