How to get something from the state / store inside a redux-saga function?

前端 未结 3 390

How do I access the redux state inside a saga function?

Short answer:

import { select } from \'redux-saga/effects\';
...
let data =          


        
3条回答
  •  一个人的身影
    2020-12-22 21:00

    This is what "selector" functions are for. You pass them the entire state tree, and they return some piece of the state. The code that calls the selector doesn't need to know where in the state that data was, just that it was returned. See http://redux.js.org/docs/recipes/ComputingDerivedData.html for some examples.

    Within a saga, the select() API can be used to execute a selector.

提交回复
热议问题