getstate

redux getState() doesn't return the updated state

孤街醉人 提交于 2019-12-07 23:58:17
问题 The problem that made me stuck for days is that although my redux devtool shows the successful state update without any kind of mutation and with successful View component rerender, but when I call getState() it always return the initial state and doesn't care about updated state! anyone who knows what could make this kind of situation pls help me. I use react-redux and redux-thunk action.js export function test(data) { return { type: 'TEST', data }; } export function testFunc(data) { return

redux getState() doesn't return the updated state

扶醉桌前 提交于 2019-12-06 12:22:14
The problem that made me stuck for days is that although my redux devtool shows the successful state update without any kind of mutation and with successful View component rerender, but when I call getState() it always return the initial state and doesn't care about updated state! anyone who knows what could make this kind of situation pls help me. I use react-redux and redux-thunk action.js export function test(data) { return { type: 'TEST', data }; } export function testFunc(data) { return dispatch => { dispatch(test(data)) console.log('GLOBAL STATE IS :', store.getState() ) }; } reducer.js

Is using getState in a Redux Thunk good practice?

不问归期 提交于 2019-12-05 09:17:36
问题 I have seen conflicting (or just confusing, to me) answers in other questions here regarding whether using getState within an action is acceptable, or not, and I have seen quite a few times it being called an anti-pattern. For me, it seems to work great but what is the best practice for doing this if we are not to use getState ? I am using getState within a thunk to filter through an array of users that is currently connected to some mock data and being pulled into the state of the

MonoGame Key Pressed String

感情迁移 提交于 2019-12-04 14:57:28
In MonoGame, how can I read which keyboard key is pressed in the form of a String? I have tried String pressedKey = Keyboard.GetState().ToString(); , but it gives me "Microsoft.Xna.Framework.Input.KeyboardState". In games, you typically think of keys as buttons that have state rather than strings because you are usually checking if a button is up or down to move a character around, shoot, jump, etc. As others have said, you said you should use IsKeyDown and IsKeyUp if you already know what keys you want to test. However, sometimes you just want to know what keys are being pressed. For that,