Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Fixed bug while editing products in products list #88

Merged
merged 1 commit into from
Oct 9, 2022

Conversation

sameersecond
Copy link
Contributor

This PR solves #86

The following is the state of products on /admin/productlist before updating any product:
image

After editting any of the products the state of productDetails becomes (note that there is no product: {}) :
image

This causes a crash in line 47 of frontend/src/screens/ProductEditScreen.js, as product is not defined and we try to access product.name (when trying to edit any product for the second time).

if (!product.name || product._id !== productId) {
    dispatch(listProductDetails(productId))
}

Hence, all I did was update the productDetails reducer when the PRODUCT_DETAILS_RESET action is dispatched.

P.S. The above screenshots were taken using Redux DevTools web extension.

@roopeshsn
Copy link
Owner

Hi, @sameersecond Have you checked whether the error not appears after these changes?

@sameersecond
Copy link
Contributor Author

Yes, I have checked and the error does not appear anymore.

freshbey-2022-10-09_12.15.25.mp4

@roopeshsn roopeshsn merged commit 807ab11 into roopeshsn:master Oct 9, 2022
@roopeshsn roopeshsn added the hacktoberfest-accepted Accepted PR for hactoberfest label Oct 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
hacktoberfest-accepted Accepted PR for hactoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants