redux-saga

How do you update some state with a redux get function? Values not updating correctly on set

谁都会走 提交于 2019-12-13 18:16:50
问题 I currently am fetching some balances via a redux getBalances method. When the app initializes it sets 'balances' to the JSON of information, however when I call getBalances again it doesn't re-set the balances (no idea why). So right now, I'm manually trying to update the balances by calling the getBalances method then setting the result of that to balances, however I'm running into walls. All I'd like to do is getBalances again and merely set this to balances, however I'm not sure how I'd

What am I missing with Redux-Saga?

房东的猫 提交于 2019-12-13 07:36:25
问题 I've been trying to integrate Redux-Saga into my React/Redux app for a while now and there is some key part of this that I'm missing (as it doesn't want to work). My understanding of how this is supposed to work is as follows: In the rootSaga function, I fork off a "Watcher" which watches for a particular action to occur. When the watcher sees the action, it calls the handler for that action and calls the appropriate success/fail action when completed. I should use put or call to dispatch an

React / Redux / Reselect - is mapped state to props using selectors synchronous or asynchronous?

回眸只為那壹抹淺笑 提交于 2019-12-13 04:25:15
问题 In our project we are using react-redux with reselect and redux-saga In the store I have a selectedStageId along with an array of stages and a memoized selector that finds and returns the correct stage based on the id. This selector is mapped to one of my components props as this.props.selectedStage , and in one of my onClick handlers, I dispatch an action to update the selectedStageId to the id of the newly selected UI item, and then attempt to pass the new selectedStage to an edit method...

How to wait for complex redux-saga action flow to finish before rendering in next.js?

柔情痞子 提交于 2019-12-12 18:23:50
问题 I'm having issues with waiting "one action flow" to finish from start until the end. The app works as usual in client, but while doing stuff server-side it doesn't finish until the end. To clarify, I'm using both "next-redux-wrapper" and "next-redux-saga" properly, as I can achieve the delayed rendering when I use simpler flow with sagas. I think the mistake is mostly how I understand (or not) saga effects altogether. Some of the code is omitted for brevity. api.saga.js const makeRequest = ({

How to use a generator function as a callback inside a promise returned by fetch call?

纵饮孤独 提交于 2019-12-12 03:37:05
问题 return fetch(url, { credentials: 'same-origin', ...options }) .then(response => response.json()) .then(function*(response) { console.log("httpStatusCode", response.httpStatusCode) }) Is the above possible ? I'm not getting the consoled output when the callback function is a generator, which means that the control is not passing to the callback function(generator). The real reason I want to do it this way is that I have to call another fetch request using the 'call' helper function of redux

How to cancel saga task when specific action is dispatched

女生的网名这么多〃 提交于 2019-12-11 16:56:57
问题 I'm trying to figure out how to solve my problem, but I didn't find good enough solution on the web. I need to cancel checkAuth and logout tasks when action LoginActionType.REQUEST_SEND is dispatched. function* handleLoginFetch(userCredentialsAction: PayloadAction<LoginActionType, UserCredentials>) { try { const response: AxiosResponse<AuthResponse> = yield call($http.put, '/users/login', userCredentialsAction.payload); if (response.status === HttpStatusCode.OK) { yield put(login.success

How to call a function before and then depending on data update state-React-redux

谁说胖子不能爱 提交于 2019-12-11 16:42:49
问题 I've a drop down on select the saga is called and the same component must be used. The sagas are called the only thing not happening is the set state is updating before the saga call therefore the component never updates the data. recievedChangeValue=(selectVal)=>{ console.log(selectVal) if(selectVal==='Yearly'){ this.props.getYearlySales() **//call to saga** this.setState({salesData:this.props.yearlySales}) **//it updates before the called saga ends** } if(selectVal==='Decade'){ this.props

Redux saga - Worker saga not getting called on react native

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 16:08:10
问题 I am trying to handle async actions with redux saga on a simple app. It calls an api to fetch some tweets from a local proxy server. By looking at the logs, I can tell that the watcher saga is getting run, the action is being dispatched, the reducers are getting fired but the worker saga is not getting called... Here is my code - https://github.com/TechyTimo/react-native-tweets store.js import { Platform } from 'react-native'; import RootReducer from './reducers'; import { applyMiddleware,

How do I make takeLatest consider url, params, and method?

坚强是说给别人听的谎言 提交于 2019-12-11 07:50:59
问题 I'm using Saga's takeLatest to abort all requests except the latest. This works fine, but now I want to only abort requests which don't have identical url, params, and method. I know Saga uses the type attribute to compare actions (just like vanilla Redux does), but I've also added url , params , and method to my actions because I was hoping there there was some way to do something like yield takeLatestIf((action, latestAction) => { const sameType = action.type === latestAction.type; const

Can't yield json response from server with redux-saga

◇◆丶佛笑我妖孽 提交于 2019-12-11 03:23:53
问题 i am trying to use the stack react redux and redux-saga and understand the minimal needed plumbing. i did a github repo to reproduce the error that i got : https://github.com/kasra0/react-redux-saga-test.git running the app : npm run app url : http://localhost:3000/ the app consists of a simple combo box and a button. Once selecting a value from the combo, clicking the button dispatch an action that consists simply of fetching some json data . The server recieves the right request (based on