I'm making a web app where the user draws bounding boxes around objects in an image.
- How I'm using React's local state: I store the properties of the rectangle while the user is still drawing (i.e. during
mouseMove
beforemouseUp
). - How I'm using Redux's global store: Once
mouseUp
fires, the drawing finishes, and updates to the rectangle are no longer made. I want to 'commit' this rectangle to Redux.
Is this the right and/or canonical way to handle state management?
I also want to pass both the React and Redux states (i.e. both the rectangle being drawn right now as well as the rectangles that have been 'committed' already in Redux) as props to a child React component.
Is this possible with react-redux
's mapStateToProps
? I can't seem to find a way to combine React state and Redux state together in mapStateToProps
.