So I'm having an error message - Uncaught TypeError: Cannot read properties of undefined (reading 'params')
AddOrUpdateProduct.js
function mapStateToProps(state, ownProps) {
const productId = ownProps.match.params.productId;
const product =
productId && state.productListReducer.length > 0
? getProductById(state.productListReducer, productId)
: {}
return {
product: product,
products: state.productListReducer,
categories: state.categoryListReducer
}
}
App.js
<Routes>
<Route path="/" exact element={<Dashboard />} />
<Route path="/product" exact element={<Dashboard />} />
<Route path="/saveproduct/:productId" element={<AddOrUpdateProduct />} />
<Route path="/cart" exact element={<CartDetail />} />
</Routes>
I'm trying to get the productid in the url with 'ownProps.match.params.productId'