2017-04-20 7 views
0

私は以下の私のコードで間違っているものを、私は他の方法でその機能を再利用したいので、クラス内のパブリックメソッドを持つようにしたいReact.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.JSクラスで再利用できるメソッド/関数を作成します。

のエラーを得ましたか?最初は、エラーの原因となっている間、私の場合、第2の1の動作

import Your_Component_Name from '../components/xyz.js'; 

componentDidMount() { 
    this.getCurrentMonthData('2017-10-1', '2017-12-1'); 
} 
getCurrentMonthData = (from, to) => { 
    //do something 
} 
OtherFunc =() => { 
    this.getCurrentMonthData('2017-10-1', '2017-12-1'); 
} 
+0

これはクラス本体またはコンストラクタ内にありますか? –

+0

レンダー機能に問題があります。レンダリング機能を記述していないか、何も返されていません。 –

答えて

0
import {Your_Component_Name} from '../components/xyz.js'; 

このようなコンポーネントをインポートしてみてください。

関連する問題