別の.jsファイルに関数を記述してコードを分割しています。this.props.dispatchを関数に代入する方法は?
問題は、新しい.jsファイルでクラスを使用していないため、私のredux接続関数へのアクセス権がないことです。
物事をクリアするには:
これは私が私のユーザーを使用するためには
@connect((store) => {
return {
bar_change:store.bar_change
};
})
export default class Bardoctor extends React.Component {
constructor(props) {
super(props);
}
barChange(arg0){
//function code...
this.props.dispatch(user.changeBarNum(arg0,"bar_change_doctor"));
this.props.dispatch(user.sendBarDataDoctor("doctor_bar_send",temp_arr, flag_it, arg0));
}
ファイル別のJSに移動したい私のクラスの内部機能(barChange)です。私はthis.props.dispatchを持っている必要があります。 barChangeファンクションを別の.jsファイルにパックし、そのファンクションをエクスポートしてクラスに呼び出すと、this.props.dispatchをどのように使用しますか?例えば
:
import * as user from "../actions/asyncCAll.js"
export function barChange(arg0, prop_arr, prop_next, string_change, string_send){
//function code...
dispatch(user.changeBarNum(arg0,string_change));
dispatch(user.sendBarDataPatient(string_send, temp_arr, flag_it, arg0));
}
'dispatch'メソッドを渡します。 –