2017-12-11 3 views
0

私のコンポーネントの1つにonClickイベントが格納された状態で、Reduxで非常に単純な変更状態を実行しようとしていますが、わかりません。私は自分の論理、行動、そしてコンテナをすべて還元している。どのようにして、onClick関数のReduxに格納されているブール値を変更しますか?

CONTAINER:COMPONENT ON

export const ReportTableContainer = connnect((state) =>({ 
    isOpen: state.app['modal-status']['isOpen'] 
}),() =>({FetchPopupReport}))(ReportTable) 

がFUNCTION:

onCellSelect = ({idx, rowIdx}) => { 
    if(idx <= 2 && idx > 0){ 
     //where I want to change the state from false to true 
    }else if(idx > 2){ 
     console.log('passed') 
    } 
} 

REDUXのFILE:

export const logic = createLogic({ 
    type: FetchRoiReport, 
    process({ getState, action, api}, dispatch, done) { 
     dispatch(ModalStatus({isOpen: false})) 
     dispatch(Loading({report: true})); 
     api.get(URL) 
     .then(obj => { 
      dispatch(Loading({isOpen: false})); 
      dispatch(FetchRoiReportSucceeded(obj)) 
      dispatch(ModalStatus({isOpen: false})); 
      done(); 
     }).catch(err => { 
      dispatch(Loading({isOpen: false})); 
      dispatch(ModalStatus({status: false})); 
      dispatch(FetchRoiReportFailed("ERROR")); 
      done(); 
     }) 
     } 
    }); 

私はちょうど私が思う.then()が真

答えて

1

に変更したいです君は店舗で発送される還元状態を変更したい場所からアクションを呼び出さなければなりません。リデューサーが呼び出され、最終的に状態が「true」に変わり、コンポーネントのレンダリングが呼び出されます。

現在の 'redux'ファイルのようなものです.FetchRoiReportアクションが処理され、必要に応じてLoading、FetchRoiReportSucceeded、ModalStatusが送出されます。減速機は、これらのアクションを処理し、状態を変更する必要があります(新しい状態を作成することによって)

関連する問題