Coder Social home page Coder Social logo

crwn-clothing-v2's Introduction

Hello! My name's Yihua ๐Ÿ‘‹

I'm a developer that loves simplifying things. I love breaking down complex problems into simple, easy to understand solutions. I Currently live in Toronto as a software developer. In my spare time, I create courses on software development and mentor new developers.

crwn-clothing-v2's People

Contributors

zhangmyihua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crwn-clothing-v2's Issues

Reducer Section - Bugs with cart and checkout [branch lesson 28 & 29] (with solution)

Reducer section (lesson 28 to 29)

Hello everyone ๐Ÿ‘‹

I thought I might save someone some time with problem solving the issue with the source code here. If you are following and coding along with this repo and the videos and you get to the end of the section you will be left with a couple bugs.

You will find a bug that will affect the cart, as a quick QA example

If you add an item to the cart ;

  • the cart icon will remain at 0
  • proceed to checkout and you will see the item there however the cart total will be 0

If you add a second item to the cart ;

  • the cart icon will update to 1
  • proceed to checkout and you will see the two items in your cart

Further there will be issues with calculating the total amount, increasing/decreasing on checkout page etc.

Source Code (according to the video and GitHub repo)


Click to expand export const CartProvider = ({ children }) => { const [isCartOpen, setIsCartOpen] = useState(false); const [{ cartCount, cartTotal, cartItems }, dispatch] = useReducer( cartReducer, INITIAL_STATE ); const updateCartItemsReducer = (cartItems) => { const newCartCount = cartItems.reduce( (total, cartItem) => total + cartItem.quantity, 0 ); const newCartTotal = cartItems.reduce( (total, cartItem) => total + cartItem.quantity * cartItem.price, 0 ); const payload = { cartItems, cartCount: newCartCount, cartTotal: newCartTotal, }; dispatch(createAction(CART_ACTION_TYPES.SET_CART_ITEMS, payload)); };

Solution Bug Fix


Click to expand export const CartProvider = ({ children }) => { const [ { cartItems, isCartOpen, cartCount, cartTotal }, dispatch] = useReducer( cartReducer, INITIAL_STATE ); const updateCartItemsReducer = (newCartItems) => { const newCartCount = newCartItems.reduce( (total, cartItem) => total + cartItem.quantity, 0 ); const newCartTotal = newCartItems.reduce((total, cartItem) => total + cartItem.quantity * cartItem.price, 0); const payload = { cartItems: newCartItems, cartTotal: newCartTotal, cartCount: newCartCount, }; //importing from createAction from utils -> reducer dispatch( createAction(CART_ACTION_TYPES.SET_CART_ITEMS, payload)); };

FInal Note

The issue is the wrong object is passed in as props and then reduce is run on the wrong props. Further a mistake in the payload causing issues.

I leave this here as an issue as I see that Pull Requests are rarely merged.
I hope this helps anyone who is getting stuck here

โœŒ๏ธ

user.context.jsx lesson 26

dispatch({ type: USER_ACTION_TYPES.SET_CURRENT_USER, currentUser: user });

should been
dispatch({ type: USER_ACTION_TYPES.SET_CURRENT_USER, payload: user });

lecture 145 user.context.jsx line 36

line 36 dispatch({ type: USER_ACTION_TYPES.SET_CURRENT_USER, currentUser: user });
should be
dispatch({ type: USER_ACTION_TYPES.SET_CURRENT_USER, payload: user });

Nothing displays after I Login and press Shop

I'm having problems with the Complete React Developer in 2023 (w/ Redux, Hooks, GraphQL): Zero to Mastery course.
I've been working in the [Firebase Database Storage] section for sometime now.
Just to save some questions to come at me, I've downloaded the scripts from the git site up to Branch Lesson 21 and yes I put my login info for firebase utility.
The users and the collections are there on the firebase site .

The app starts up okay.
After I sign in and click shop nothing appears except the Crown Icon and navigation
For some strange reason it has been working that way for quite through a bunch of videos.
Originally I thought it was the way I might have typed something, so I been pulling the code from the git site

I get the same issue no matter if its Chrome or Firefox
but in addition to my main problem If I try using Firefox, when the initial page displays, everything is crunched down

Please help if you can as this is certainly frustrating

Mike
[email protected]
here's a snap shot of my console
console
network

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.