Posts

Showing posts with the label react js

protected routes in reactjs

  Navbar.js import { Link, Route, Routes } from "react-router-dom" import Home from './Home' import Login from './Login' import Profile from './Profile' import Contact from './Contact' import CreateToken from './Token.js' import Protected from './Protected' export default function Navbar() {     return (         <>             <nav class="navbar navbar-expand-lg bg-body-tertiary">                 <div class="container-fluid">                     <Link class="navbar-brand" href="#">Navbar</Link>                     <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">           ...

list rendering in react

 import { useEffect, useState } from "react"; function App() {   const [product, setProduct] = useState();   useEffect(() => {     fetch('https://dummyjson.com/products')       .then(res => res.json())       .then(data => {         console.log(data.products);         setProduct(data.products);       });   }, []);   return (     <>       <h3>Main App</h3>       <br></br>       <br></br>       <table>         <tr>           <th>Title</th>           <th>Description</th>           <th>Price</th>         </tr>         <tbody>           { ...