简体   繁体   中英

Unexpected Token Error React

I keep getting an Unexpected Token error when I run the code, I can't seem to figure out the error. Am sure it is a syntax error or something but I can not see it. It occurs at the "return" on the mapStateToProps function. Kindly any help appreciated. Again to clarify, I get an Unexpected Token Error at the "return" on the mapStateToProps function.

import React, { Component } from 'react';
import { connect } from 'react-redux';
import * as css from './Sidebar.css';


class Sidebar extends Component {
  render(){
    return(
      <div>
                <div id="wrapper">


                <div id="sidebar-wrapper">
                    <ul class="sidebar-nav">
                        <li class="sidebar-brand">
                            <a href="#">

                            </a>
                        </li>
                        <li class="menu-list">
                            <a href="#">Dashboard</a>
                        </li>
                        <li class="menu-list">
                            <a onClick={this.props.onClickRenderContent} >Content</a>
                        </li>
                        <li class="menu-list">
                            <a onClick={this.props.onClickRenderStore}>Store</a>
                        </li>
                        <li class="menu-list">
                            <a onClick={this.props.onClickRenderEvents}>Events</a>
                        </li>
                        <li class="menu-list">
                            <a onClick={this.props.onClickRenderProfile}>Profile</a>
                        </li>

                    </ul>
                </div>
      </div>
    );
  }
}



const mapStateToProps = state => {
  return {
    content: state.activeComponent.content,
    events: state.activeComponent.events,
    profile: state.activeComponent.profile,
    store: state.activeComponent.store

  };
};



const mapDispatchToProps = dispatch => {
  return {
    onClickRenderContent :() => dispatch({ type: 'SHOWCONTENT'}),
    onClickRenderEvents :() => dispatch({ type: 'SHOWEVENTS'}),
    onClickRenderProfile :() => dispatch({ type: 'SHOWPROFILE'}),
    onClickRenderStore :() => dispatch({ type: 'SHOWSTORE'})

  };
};

export default connect(mapStateToProps, mapDispatchToProps)(Sidebar);

There's a missing </div> in your code. Probably the one that closes <div id="wrapper">

您需要在HTML部分的末尾再添加一个</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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