我在react js中有以下代码。
class Posts extends Component {
render() {
return (
{console.log('test')}
);
}
}
运行此代码后,我收到错误
Parsing error: Unexpected token, expected ","
8 | return (
> 9 | {console.log('test')}
| ^
10 | );
11 | }
12 | }
更新
用父标签包装它会返回相同的错误
> 9 | <div>
| ^
10 | {console.log('nothing')}
11 | </div>
更新
这是全班同学
import React, { Component } from 'react';
import { connect } from 'react-redux';
class Post extends Component {
render() {
return (
<div>
{console.log('test')}
</div>
);
}
}
const mapStateToProps = (state) => {
return {
posts: state
}
};
export default Post;