babel watch SyntaxError:意外令牌 [英] babel watch SyntaxError: Unexpected token
本文介绍了babel watch SyntaxError:意外令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用babel观看jsx文件时.但是存在语法错误.
When I uses babel to watch a jsx file. But there is a syntax error.
在此之前,我使用react-tools进行观看,一切都很好.
Before that, I uses react-tools to watch, and everything is fine.
SyntaxError: assets/js/chat/chat.jsx: Unexpected token (258:16)
256 | if (this.props.isOpen) {
257 | return (
> 258 | <div className="modal-overlay">
| ^
259 | <ReactCSSTransitionGroup transitionName={this.props.transitionName}>
260 | <div className="chat-modal">
261 | {this.props.children}
以下是我的代码.
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
var Modal = React.createClass({
render: function() {
if (this.props.isOpen) {
return (
<div className="modal-overlay">
<ReactCSSTransitionGroup transitionName={this.props.transitionName}>
<div className="chat-modal">
{this.props.children}
</div>
</ReactCSSTransitionGroup>
</div>
)
} else {
return <div className="modal-overlay"><ReactCSSTransitionGroup transitionName={this.props.transitionName}/></div>
}
}
});
推荐答案
前几天,我遇到了类似的问题.看来babel现在需要一些其他插件才能与react一起使用.
I had a similar issue the other day. It seems that babel now needs some additional plugins to work with react.
请参阅以下SO问题的答案: babel-loader jsx SyntaxError:意外令牌
See the answer in this SO question: babel-loader jsx SyntaxError: Unexpected token
这篇关于babel watch SyntaxError:意外令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文