redux-saga加cancel钩子的方法

import axios, { CancelToken } from 'axios'
import { CANCEL } from 'redux-saga'

export default function fetchAPI(url) {
  const source = CancelToken.source()
  const request = axios.get(url, { cancelToken: source.token })
  request[CANCEL] = () => source.cancel()
  return request
}

你可能感兴趣的:(redux-saga加cancel钩子的方法)