This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm install mongoose express cors dotenv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm init -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| // importing the library | |
| import styled from 'styled-components'; | |
| // defining the styles | |
| const AddButton = styled.button` | |
| margin: 40px; | |
| border: 5px black; | |
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import styles from './cart.module.scss'; | |
| const Cart = () => ( | |
| <div className="btnGrp"> | |
| <Button className="styles.addBtn"> Add Me </Button> | |
| <Button className="styles.addBtn"> Add Me </Button> | |
| </div> | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import './cart.css'; | |
| const Cart = () => ( | |
| <div className="btnGrp"> | |
| <Button className="addBtn"> Add Me </Button> | |
| <Button className="addBtn"> Add Me </Button> | |
| </div> | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // cart.css | |
| .addBtn { | |
| margin: 40px; | |
| border: 5px black; | |
| } | |
| .btnGrp { | |
| font-size: 16px; | |
| text-align: center; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div> | |
| Home page cart:{countContext.countState} | |
| <button onClick={() => countContext.countDispatch("increment")}> | |
| Add Item | |
| </button> | |
| <button onClick={() => countContext.countDispatch("decrement")}> | |
| Remove Item | |
| </button> | |
| <button onClick={() => countContext.countDispatch("reset")}>Clear</button> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useContext } from "react"; | |
| import { CountContext } from "../App"; | |
| function ComponentA() { | |
| const countContext = useContext(CountContext); | |
| return ( | |
| <div> | |
| Home page cart:{countContext.countState} | |
| <button onClick={() => countContext.countDispatch("increment")}> | |
| Add Item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useReducer } from "react"; | |
| import ComponentA from "./components/ComponentA"; | |
| import ComponentB from "./components/ComponentB"; | |
| import ComponentC from "./components/ComponentC"; | |
| const initialState = 0; | |
| const reducer = (state, action) => { | |
| switch (action) { | |
| case "increment": | |
| return state + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const reducer = (state, action) => { | |
| switch (action) { | |
| case "increment": | |
| return state + 1; | |
| case "decrement": | |
| return state - 1; | |
| case "reset": | |
| return initialState; | |
| default: | |
| return state; |