react state 에러

취미생활/react|2018.11.29 17:25

SyntaxError: C:\project\demo\src\main\jsx\Counter.jsx: Support for the experimental syntax 'classProperties' isn't currently enabled (4:9):


import React, { Component } from 'react';

class Counter extends Component {
  state = { //이부분에 에러날때 
    number: 0
  }
  ...



처리방법


package.json 에 아래내용추가. 

plugins만 추가해도 될것같기도함.


  ...
  "babel": {
    "presets": [
      "@babel/preset-env",
      "@babel/preset-react"
    ],
    "plugins": [
      "@babel/plugin-proposal-class-properties"
    ]
  }


태그 :

댓글(0)