I'm trying to write my own decorator. Here is the decorator code:

const userAuth = observable({ isAuth: true, }); export const isAuth = () => { if (userAuth.isAuth) { return ( <Redirect to="/dashboard" /> ); } return ( <Redirect to="/login" /> ); }; export default { isAuth }; 

In another file, I connect it as follows:

 import { isAuth } from './routes/auth/authChecker'; @isAuth() class App extends React.Component { .... 

I get an error ...

 [dev:server] /home/dmitry/web/tennis-front/node- seed/tmp/bundle.js:50261 [2] import createReactClass from 'create-react-class'; [2] ^^^^^^ [2] [2] SyntaxError: Unexpected token import 

    1 answer 1

    Decorator syntax is not supported in the create-react-app out of the box, so babel-plugin-transform-decorators-legacy should be added.

    Read more here.