Using PubSubJS in React
Here I demonstrate how to use PubSubJS to allow a React component to listen for changes to some external object (external to the React application). The problem being solved: I want an array of strings to exist globally such that any Javascript code can modify it (primarily to add to it), while at the same time providing a method for a visual component to listen to state changes on that array and update an on-screen list of those strings. Main use case I had in mind: helping me to write React code via codepen.io when on my iPad and have no access to Developer Tools, which means I can't see console.log messages. Helpful resouce: Communication Between Independent Components in React using PubSubJS PubSubJS API lives at: https://www.npmjs.com/package/pubsub-js . See my live example of this at codepen.io . The HTML is extremely basic, just providing a root object for React to hook into. <div id="root"></div> The Javascript contains all the re