Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ decorator in component breaks build #455

Closed
gerwinbrunner opened this issue Sep 14, 2016 · 2 comments
Closed

@ decorator in component breaks build #455

gerwinbrunner opened this issue Sep 14, 2016 · 2 comments

Comments

@gerwinbrunner
Copy link

I have a simple component which uses @radium decorators

import React from 'react';
import { NavItem } from 'rebass';
import Icon from 'react-geomicons';
import Radium from 'radium';

@Radium
export default class StatusIndicator extends React.Component {
  checkStatus() {
    const { status } = this.props;
    // console.log('StatusIndicator',status);
    switch(status) {
      case 'OPERATION-STATE-STOPPED':
        return 'stopped';
      case 'OPERATION-STATE-REGULATING':
        return 'regulating';
      default:
        return 'warning';
    }
  }
}

When storybook tries to run it throws this error

ERROR in ./imports/ui/components/StatusIndicator.jsx
Module build failed: SyntaxError: Unexpected token (6:0)

  4 | import Radium from 'radium';
  5 | 
> 6 | @Radium
    | ^
  7 | export default class StatusIndicator extends React.Component {
  8 |   checkStatus() {
  9 |     const { status } = this.props;

 @ ./stories/StatusIndicator.js 11:23-78

Any idea how to solve this?

@thani-sh
Copy link
Contributor

Hi @gerwinbrunner, can you try adding a custom .babelrc file (more info)

@arunoda
Copy link
Member

arunoda commented Sep 15, 2016

As thanish mentioned we don't support this. Add a stage-0 babel preset as mentioned on the docs.

Or radium has a way to use without decorators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants