我的代码中有语法错误,我不知道为什么。这与我使用 refs 的方式有关吗?
export default class ToggleMenu extends React.Component {
showRight: function() {
this.refs.right.show();
}
render() {
return (
<div>
<button onClick={this.showRight}>Show Left Menu!</button>
{/*
<Menu ref="right" alignment="right">
<MenuItem hash="1">First</MenuItem>
<MenuItem hash="2">Second</MenuItem>
<MenuItem hash="3">Third</MenuItem>
</Menu>
*/}
</div>
);
}
}
这是错误:
./src/components/ToggleMenu/
ToggleMenu.js
模块构建失败:SyntaxError: Unexpected token (13:14)showRight: function() { this.refs.right.show(); }