reactjs - React-Redux @connect syntax error -


i'm new using react , redux, i'm building simple todos application. writing application using create-react-app tool in command line.

the issue

i went other blogs , post , others have mentioned missing npm plugin transform decorators "transform-decorators-legacy", added dependencies along babel, still receiving same error.

syntax error: unexpected token (9:0)     7 | import './app.css';    8 | >  9 | @connect((store) => {      | ^   10 |   return {   11 |     user: store.user.user   12 |   } 

my code

import react, { component } 'react'; import { connect } 'react-redux';  import todos './components/todos'; import todo './components/todo';  import './app.css';  @connect((store) => {   return {     user: store.user.user   } }) class app extends component {   constructor(){     super()     this.state = {       name: 'brad',       todos: [         {           id: '001',           name: 'take out trash',           completed: false         },         {           id: '002',           name: 'meeting boss',           completed: false         },         {           id: '003',           name: 'go out dinner',           completed: false         }       ]     }   }   render() {     return (       <div classname="app">         <h1>hello</h1>         <todos name={this.state.name} todos={this.state.todos}/>         <todo/>       </div>     );   } }  export default app; 

my dependencies

package.json

{   "name": "react-redux-project",   "version": "0.1.0",   "private": true,   "dependencies": {     "axios": "^0.16.2",     "react": "^15.6.1",     "react-dom": "^15.6.1",     "react-redux": "^5.0.6",     "redux": "^3.7.2",     "redux-logger": "^3.0.6",     "redux-promise-middleware": "^4.3.0",     "redux-thunk": "^2.2.0"   },   "devdependencies": {     "babel": "^6.23.0",     "babel-plugin-transform-decorators-legacy": "^1.3.4",     "react-scripts": "1.0.11"   },   "scripts": {     "start": "react-scripts start",     "build": "react-scripts build",     "test": "react-scripts test --env=jsdom",     "eject": "react-scripts eject"   } } 

any help/knowledge appreciated thanks!

try this:

const statemap = (state) => {     console.log('state', state);     return {         //something state     }; };  export default connect(statemap)(app); 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -