Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
2sdarko opened this issue Oct 18, 2021 · 2 comments
Open

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

2sdarko opened this issue Oct 18, 2021 · 2 comments

Comments

@2sdarko
Copy link

2sdarko commented Oct 18, 2021

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
Copy link
Author

2sdarko commented Oct 18, 2021

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
Copy link

Rhim967 commented Nov 3, 2021

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?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants