Making the ColorPicker Dialog Reusable
Explore how to make a ColorPicker dialog reusable within a Redux-managed modal system. Learn to pass pre-built action objects to dialogs to handle return values correctly, update state through reducers, and avoid storing non-serializable values in the Redux store. Understand alternatives like redux-promising-modals for handling dialog results using middleware and promises.
We'll cover the following...
Using the Dialog Result Value
Unfortunately, now we have a problem. We can forward the current color value to the ColorPickerDialog as part of the “description” that we’re storing in state, and use that as the initial color value in the dialog. However, we need some way to not only retrieve the final color value when the user clicks the “Select” button, but also actually use it to update the right field in the unit info reducer.
The obvious solution is to simply pass a callback function as another prop to the dialog, but that means we’d be storing the callback ...