简体   繁体   English

运行已编译的JSX时发生React Reflux错误,但使用Transformer时不发生

[英]React Reflux error when running compiled JSX but not when using transformer

When I include my JSX code directly in a script tag 当我直接在脚本标签中包含我的JSX代码时

<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 我的react程序会加载并正常运行,但是如果我将JSX编译为javascript文件并将其包含在内

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

I get the following error 我收到以下错误

TypeError: listenable is undefined http://localhost/js/reflux.js Line 669 TypeError:可听是未定义的http://localhost/js/reflux.js第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? 使用Reflux时,需要做一些特殊的事情来预编译JSX吗?

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: 在index.html中,我按以下顺序加载了脚本:

components.js
actions.js
store.js

Moving the components to last fixed the error. 将组件移动到最后可修复错误。

actions.js
store.js
components.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM