divanov11 / proshop_django

403 stars 426 forks source link

Can't get "order._id" in the PlaceOrderScreen.js file #21

Open 2sdarko opened 2 years ago

2sdarko commented 2 years ago

Below is the full error, please help

TypeError: Cannot read properties of undefined (reading '_id') (anonymous function) src/screens/PlaceOrderScreen.js:31 28 | 29 | useEffect(() => { 30 | if (success) {

31 | history.push(/order/${order._id}) | ^ 32 | dispatch({ type: ORDER_CREATE_RESET }) 33 | } 34 | },[success, history]) View compiled ▶ 22 stack frames were collapsed. (anonymous function) src/actions/orderActions.js:42 39 | payload: data 40 | }) 41 | 42 | dispatch({ | ^ 43 | type: CART_CLEAR_ITEMS, 44 | payload: data 45 | })

2sdarko commented 2 years ago

Yes, I used the back-tic character to rap around the statement, so the syntax is all correct, spent many hrs figuring out the issue but so far no luck, please help.

Rhim967 commented 2 years ago

i have problem with order._id too React Hook useEffect has missing dependencies: 'dispatch' and 'order._id'. Either include them or remove the dependency array why is that happened? if orderItem == cartItem it shuld has an _id can you help with fixing this problem?