To get something from the state or store inside a React Redux-Saga function, we call the select
function.
For instance, we write
export const getProject = (state) => state.project;
// Saga
export function* saveProjectTask() {
while (true) {
yield take(SAVE_PROJECT);
let project = yield select(getProject);
yield call(fetch, "/api/project", { body: project, method: "PUT" });
yield put({ type: SAVE_PROJECT_SUCCESS });
}
}
to call select
with the getProject
to get the project
state from the store.