redux

How do I resolve 'Property 'type' is missing in type 'AsyncThunkAction' using Redux Toolkit (with TypeScript)?

爷,独闯天下 提交于 2020-06-17 15:49:09
问题 I'm using Redux Toolkit with the thunk/slice below. Rather than set the errors in state, I figure I could just handle them locally by waiting for the thunk promise to resolve, using the example provided here. I guess I could avoid doing this, and perhaps I should, by setting an error in the state but I sort of want to understand where I went wrong on this. Argument of type 'AsyncThunkAction<LoginResponse, LoginFormData, {}>' is not assignable to parameter of type 'Action<unknown>'. Property

Redux: My state is receiving '@@redux/INITi.8.g.w.a.m' Redux state not updating

大憨熊 提交于 2020-06-17 11:33:00
问题 I've been debugging why my state hasn't been changing and noticed this being logged in my reducer: { type: '@@redux/INITi.8.g.w.a.m' } This is the store which includes state, action types, reducer, actions: /* initial state */ import axios from 'axios'; export var usersStartState = { accountNotVerified: null, isLoggedIn: false, error: true, userAvatar: 'uploads/avatar/placeholder.jpg' }; /* action types */ export const actionTypes = { RESET_USER_ACCOUNT_IS_VERIFIED: 'RESET_USER_ACCOUNT_IS

Redux: My state is receiving '@@redux/INITi.8.g.w.a.m' Redux state not updating

Deadly 提交于 2020-06-17 11:28:05
问题 I've been debugging why my state hasn't been changing and noticed this being logged in my reducer: { type: '@@redux/INITi.8.g.w.a.m' } This is the store which includes state, action types, reducer, actions: /* initial state */ import axios from 'axios'; export var usersStartState = { accountNotVerified: null, isLoggedIn: false, error: true, userAvatar: 'uploads/avatar/placeholder.jpg' }; /* action types */ export const actionTypes = { RESET_USER_ACCOUNT_IS_VERIFIED: 'RESET_USER_ACCOUNT_IS

how to send value to action redux in react hooks

断了今生、忘了曾经 提交于 2020-06-17 09:40:28
问题 I have a fetchLatest (limit, page) action, how do I send param to the fetchLatest function when the more load button is clicked? this is an example of an action with the fetchLatest function (page, limit) export const fetchLatest = (page, limit) => { return dispatch => { dispatch(initDataStarted()) api.get(`web/article/filterBy/lastest?page=${page}&limit=${limit}`) .then((res) => { dispatch({ type: appConstants.GET_LATEST, payload: { latest: res.data.data } }) }) } } reducer Latest const

React-Redux: Value passing from one page to another

允我心安 提交于 2020-06-17 09:38:26
问题 Hi I am building an eCommerce app using the MERN stack but I'm pretty much a beginner to these technologies. I'm having an issue with redux passing the user input value to a new page. This is the reducer const PurchaseReducer=(state={},action)=> { switch(action.type){ case 'PURCHASE': return action.payload; default: return state; } } export default PurchaseReducer; This is the action const setPurchase=(type,payload)=>{ return{ type:type, payload: payload } } export default setPurchase; Since

Tool to find which states are affected after change in one state redux

我是研究僧i 提交于 2020-06-17 09:35:06
问题 Redux is a great library to use with React. However I am facing an issue, when you update root state through reducer it looks through all the components and re renders them if they are subscribed to that state. And this is causing me a lot of trouble because I am working on a complex project which has too many components and changing one's state does affect something else. For eg. I have a root state which composed of, RootState LayerState DocumentState blah, blah, blah And there are views

Tool to find which states are affected after change in one state redux

蹲街弑〆低调 提交于 2020-06-17 09:35:06
问题 Redux is a great library to use with React. However I am facing an issue, when you update root state through reducer it looks through all the components and re renders them if they are subscribed to that state. And this is causing me a lot of trouble because I am working on a complex project which has too many components and changing one's state does affect something else. For eg. I have a root state which composed of, RootState LayerState DocumentState blah, blah, blah And there are views

How to fetch data in React/Redux from mongoose/mongodb using router to reflect changes in state of component?

孤人 提交于 2020-06-17 09:08:10
问题 Trying to render a component only the first time user logs into my MERN app to show a questionnaire, otherwise user is taken to the dashboard. I am able to manipulate redux state to show firstLogin as changing in my auth reducer by using an action that sets firstlogin to true (independent of the FirstLogin value changed in my database) after the user fills the questionnaire and even update the value of FirstLogin in the User's collection in my mongodb. I am sharing my authActions authReducer

mapStateToProps doesn't change state

…衆ロ難τιáo~ 提交于 2020-06-17 00:07:35
问题 I'm new to redux and want to learn it, I want to make redirect to dashboard content after succesful login, here is my code: class Dashboard extends Component { state = { logged: false }; render() { const { classes } = this.props; console.log(this.state.logged) return ( <div> {this.state.logged ? <div> <p>Hello</p> </div> : Login() </div> )} } const mapStateToProps = (state, props) => { return { logged: state.logged } } export default connect(mapStateToProps)(Dashboard) reducer: const

mapStateToProps doesn't change state

蓝咒 提交于 2020-06-17 00:07:27
问题 I'm new to redux and want to learn it, I want to make redirect to dashboard content after succesful login, here is my code: class Dashboard extends Component { state = { logged: false }; render() { const { classes } = this.props; console.log(this.state.logged) return ( <div> {this.state.logged ? <div> <p>Hello</p> </div> : Login() </div> )} } const mapStateToProps = (state, props) => { return { logged: state.logged } } export default connect(mapStateToProps)(Dashboard) reducer: const