Search code examples
javascriptreactjsrefluxjs

React Reflux error when running compiled JSX but not when using transformer


When I include my JSX code directly in a script tag

<script type="text/jsx" src="jsx/components.jsx"></script>

my react program loads and works properly, but if I compile my JSX to a javascript file and include it

<script src="js/components.js"></script>

I get the following error

TypeError: listenable is undefined http://localhost/js/reflux.js Line 669

I'm compiling with the following command

jsx -x jsx/ js/

Is there something special that needs to be done to pre-compile JSX when using Reflux?


Solution

  • I was finally able to find a solution to this. It was a problem with my code, although a subtle one. In my index.html, I had the scripts loading in the following order:

    components.js
    actions.js
    store.js
    

    Moving the components to last fixed the error.

    actions.js
    store.js
    components.js