I have the following code:
main.js
submit(v) {
console.log(v);
const price = v.get("price");
}
render() {
<form onSubmit={handleSubmit(this.submit)}>
<Field
name="products"
categoryId={categoryId}
component={MyComponent}
/>
<MySubmitComponent
confirm={handleSubmit(this.submit)}
/>
</form>
}
MyComponent.js
{this.props.products.map((product, index) => (
<ProductDetails
productId={product.productId}
price={product.price}
/>
))}
ProductsDetails.js
<Field
name="price"
price={price}
component={PriceText}
initialValues
/>
const selector = formValueSelector("products");
const mapStateToProps = (state, ownProps) => {
return {
initialValues: { productId: ownProps.productId },
productId: selector(state, "productId")
};
};
ProductsDetails= connect(mapStateToProps)(ProductsDetails);
When I change the price of a product and press submit, the variable values in the submit function contains only the new price of the product without its productId. I also need the productId to inform the appropriate product. What do I miss?