I have my state in Redux and I use the react-redux connector to bind it in my React application. During initial startup, where the state is set, the connection works fine. However, when I update part of the state in my reducer, it is not read as modified with React, so the component does not display again. When I do another action that forces the render, the state was actually changed.
This seems to be due to the fact that the state was not recognized as changed, and in the response-redux method for wrapWithConnect, the storeChanged and procsChanged objects are both evaluated as false after the first run. The key may be that the reduction reaction is compared at a shallow level in these tests.
The question " what do I need to do to get React to display changes in my state when the state changes in Redux "
The corresponding part of the state is below
let thisOrder = Immutable.fromJS( { "projectNumber": '', "orderHeader": { "order_id": "", "firstname": "", "lastname": "", "address1": "", ), "orderProducts": [], "lastOperation": ''} );
The section that is being updated is orderProducts, an array of products that basically looks like
orderProducts:[{productSKU:'Y54345',productDesc:'What it is',price:"4.60",qty:2}, {productSKU:'Y54345',productDesc:'What what is',price:"9.00",qty:1}]
When updating qty or price in the gearbox below (caused by an action), the resulting newState has changes
case OrderConstants.ORDER_PRODUCT_UPDATE:{ let productList = updateProductList( action.updateProduct, state.get( 'orderProducts' )) let newState = state.update( 'orderProducts', productList).set('lastOperation', action.type); return newState;}
And finally, the React control component, which then sends the downstream props
render: function () { return ( <div> <ProductList updateOrder={this.updateOrder()} products={this.props.products}/> {this.submitContinueButton()} {this.submitButton()} {this.cancelButton()} </div> </div> ) } } );
All of the above is clipped to the relevant sections. Please note that the code works to display product information on the lower components at boot time. This is when updating the price or quantity that the update does not occur.