5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

es6でrefluxjsするときのmixin方法

Posted at

babelを使ってES6でRefluxJSを使ってみたところReactのmixinを使ってリスナーを指定する部分ができなくて困ってしまったのでメモ。

classではなくfunctionをexportするようにして、function内でclass作成する。
classを作成したらreact-mixinというライブラリを使ってmixinする。
なんかもっといい方法ありそうな気はする。

my_component.js
import React from "react";
import ReactMixin from 'react-mixin';

export default function CreateMyComponent(store) {
  class MyComponent extends React.Component {
    render: { ... }
  }
  ReactMixin(MyComponent.prototype, Reflux.listenTo(store, "onValueChange"));
  return MyComponent;
}
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?