I am using React-router-v4 with redux-saga. my problem is once user is logged in I want to redirect him to home page so from the answer mentioned here with {withRouter}
I tried but it didn't work, can anyone please let me know how should I do with redux-saga I saw the answer here is this the only way?
below is my redux saga code
import { takeLatest } from 'redux-saga';
import {LOG_IN,LOG_INS,LOG_IN_ERROR} from '../constants/actionTypes';
import { call, put } from 'redux-saga/effects';
import {withRouter} from 'react-router';
import {login} from '../services/loginApi'
import { fetchScenario } from '../services/scenarioApi';
export default function* watchLogin() {
yield takeLatest(LOG_IN, loginSaga);
}
function* loginSaga(data) {
try {
console.log("obj in sagas",data)
const logInData = yield call(login,data.obj);
yield [put({ type:LOG_INS , logInData })];
this.props.history.push('/home')
}catch(error){
yield put({type: LOG_IN_ERROR, error: error.message})
return false
}
}