Posts

Showing posts from July, 2022

#42 Creating Cart State for Codeswear.com | NextJs Tutorial for Beginners #HarryBhai #codewithharry

 _app.js import { useEffect , useState } from 'react' import Footer from '../components/Footer' import Navbar from '../components/Navbar' import '../styles/globals.css' function MyApp ({ Component , pageProps }) {   const [ cart , setCart ] = useState ({})   const [ subTotal , setSubTotal ] = useState ( 0 )   useEffect (() => {     console . log ( "Hey I am a useEffect form _app.js" )     try {       if ( localStorage . getItem ( "cart" )){         setCart ( JSON . parse ( localStorage . getItem ( "cart" )))       }           } catch ( error ) {       console . error ( error );       localStorage . clear ()           }       }, [])     const saveCart = ( myCart ) => {     localStorage . setItem ( "cart" , JSON . stringify ( myCart ))     let subt = 0 ...

#37 tshirts page codeswear.com, codeswear.in harry bhai codewithharry@ next js course

import React from 'react' import Link from 'next/link' const Tshirts = () => {   return (     < div >       < section className = "text-gray-600 body-font" >         < div className = "container px-5 py-24 mx-auto" >           < div className = "flex flex-wrap -m-4" >             < Link href = { '/product/wear-the-code' } >< div className = "lg:w-1/5 md:w-1/2 p-4 w-full cursor-pointer shadow-lg m-5 " >               < a className = "block relative  rounded overflow-hidden" >                 < img alt = "ecommerce" className = "m-auto md:mx-0 h-[30vh] md:h-[36vh] block " src = "https://m.media-amazon.com/images/I/616C7eUWKAL._AC_UL480_FMwebp_QL65_.jpg" />               </ a >      ...