Single event in Redux app which integrates with legacy library

(Kai Schlamp) #1

I have a React Redux app that integrates some legacy Javascript library that presents a viewer (based on a canvas). The viewer uses its own data model (which I don’t have access to). There are cases when I have to trigger an event from another component than where the viewer is (e.g. reset the viewer), but I am not sure how to best integrate it into the Redux flow.

Two options come to my mind here:

  1. Use Redux to pass a state change (e.g. {reset: true}) down to the component that manages the viewer and instantly let the component call a container function to set the state back ({reset: false}). The downside is that this would render the component unnecessesarely twice.
  2. Simply bypass Redux for that and just pass the event to the viewer lib using a PubSub pattern.

Is there another, better option? Any recommendations?