proshop_django icon indicating copy to clipboard operation
proshop_django copied to clipboard

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

Open 2sdarko opened this issue 3 years ago • 2 comments

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 avatar Oct 18 '21 19:10 2sdarko

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.

2sdarko avatar Oct 18 '21 19:10 2sdarko

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?

Rhim967 avatar Nov 03 '21 05:11 Rhim967