React-redux decorators doesn't work with Meteor 1.4

Hi guys, I’m running Meteor version 1.4.2 and react-redux version 4.4.5 on my project, and when I try to use the @connect decorator from the react-redux package nothing happens, it simply doesn’t run. Here’s my code:


import { Meteor } from 'meteor/meteor';

import React, { Component } from 'react';

import { connect } from 'react-redux';

import ArticleEditor from '../../pages/ArticleEditor.jsx';

@connect((store) => {
  console.log("@connect running");

  return { articles: store.articles }
})
export default class ArticleEditorContainer extends Component {
  componentWillMount() {
    this.sub =  Meteor.subscribe('articles');
  }

  componentWillUnmount() {
    this.sub.stop();
  }

  render() {
    return <ArticleEditor {...this.props} />;
  }
}

And when I check with the ReactDevTools there’s no sign of the @connect wrapper. However, it does work when I use it like that:

import { connect } from 'react-redux';

class ArticleEditorContainer extends Component {
  componentWillMount() {
    this.sub =  Meteor.subscribe('articles');
  }

  componentWillUnmount() {
    this.sub.stop();
  }

  render() {
    return <ArticleEditor {...this.props} />;
  }
}

export default connect((store) => { /* ... */ })(ArticleEditorContainer);

Is there a way to make the decorator work? Or ES7 decorators aren’t supported at all?

I think you need this babel plugin to make them work.

I do not use decorators myself, so I can’t say for sure.

1 Like

I suppose Meteor uses babel, is it possible to configure it using .babelrc file?

Yes, you can configure it with .babelrc.

1 Like

It does work, thanks!

1 Like