Skip to content

Commit 3cf6ced

Browse files
committed
refact: 11.Cart: The first Solution with useContext only
1 parent 83a9bd3 commit 3cf6ced

File tree

4 files changed

+3
-15
lines changed

4 files changed

+3
-15
lines changed

src/projects/11.Cart/Navbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Navbar = () => {
55
return (
66
<nav>
77
<div className='nav-center'>
8-
<h3>useReducer</h3>
8+
<h3>useContext</h3>
99
<div className='nav-container'>
1010
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
1111
<path d='M16 6v2h2l2 12H0L2 8h2V6a6 6 0 1 1 12 0zm-2 0a4 4 0 1 0-8 0v2h8V6zM4 10v2h2v-2H4zm10 0v2h2v-2h-2z' />

src/projects/11.Cart/context.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import React, { useState, useContext, useReducer, useEffect } from 'react'
1+
import React, { useState, useContext, useEffect } from 'react'
22
import cartItems from './data'
3-
import reducer from './reducer'
4-
5-
6-
const url = 'https://course-api.com/react-useReducer-cart-project'
73

84
const AppContext = React.createContext()
95

src/projects/11.Cart/index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import React from 'react'
2-
import { AppProvider,useGlobalContext } from './context'
2+
import { AppProvider} from './context'
33
import './index.css'
44
// components
55
import Navbar from './Navbar'
66
import CartContainer from './CartContainer'
7-
// items
87

98
function Index() {
10-
// if (loading) {
11-
// return (
12-
// <div className='loading'>
13-
// <h1>Loading...</h1>
14-
// </div>
15-
// )
16-
// }
179
return (
1810
<AppProvider>
1911
<main>

src/projects/11.Cart/reducer.js

Whitespace-only changes.

0 commit comments

Comments
 (0)