score:-1
dispatching an action inside a reducer is not a good move. as i understand, you have to do some update synchronously. one way is, once the first reducer is updated, where ever your are consuming that reducer go and inside componentwillreceiveprops or componentdidupdate do something like. note: before dispatching you have to import the configurestore and create a const dispatch from store.
componentwillreceiveprops(nextprops)
{
//only if user was not there previously and now user is there
if(!this.props.user && nextprops.user)
{
dispatch({type: second_action, payload})
}
}
Source: stackoverflow.com
Related Query
- how to call another reducer method with redux react
- How to implement a dynamic reducer creator for API service call in React with Redux project?
- How do i call a method within another method in react class Es6
- How does one React component call a method in another React component?
- React/ES6 -> How to call an React component class method from another component?
- In React, how do I call a function in one component (which is being rendered with React Router) from another component?
- How to unit test the output of a React component method in a React Router / Redux app with Enzyme
- React with Redux Saga - How to get data back from axios call
- React Redux Problem: How to call multiple api in your react component with React Redux Toolkit RTK queries?
- How do I update a nested Item in a different reducer (slice) with redux toolkit in a React app
- How to call a function from different component using React with Redux Form?
- how do you call a method from another react class component
- In React js from App.js how to call another javascript file (service) method to consume API calls
- How to call a sub component's method from a main component in React with Typescript?
- React + Redux too many re-renders of mapped components with another API call
- How to call a React class method in redux connect mapDispatchToProps
- How to Update Typescript React Redux State With One or More Reducer State Values
- How to call a method of a functional react component from another functional react component?
- How to call loading function with React useEffect only once
- How can I call parent method in a child React component?
- React Redux - Is adding async method in a Reducer an anti pattern?
- React Native: How to export a method with a return value?
- Calling an action from a different reducer with React and redux
- React Hooks with React Router v4 - how do I redirect to another route?
- How to handle/chain synchronous side effects that depend on another with React hooks
- How do I call a method from another class component in React.js
- How to test whether a React Component contains another component with jest?
- How do I use local state along with redux store state in the same react component?
- Is it possible to call a reducer function from another reducer function (within the same slice) using Redux Toolkit?
- How can I access state of another slice in redux with redux-toolkit?
More Query from same tag
- What is most efficient way to handle array object in react reducer?
- Why return multiple elements in React is not allowed?
- Handling a timer in React/Flux
- React App not working in internet explorer (empty div)
- how to use different IP address for development and production with react and axios
- React js Material ui Typography
- How to fix an import error using a Match object in React Router
- Can't fetch data from Firebase - unable to find "docs" in data returned despite data existing in backend
- Code is moving on before my fetch is completed
- 405 - Uncaught (in promise) Error: Request failed with status code 405
- React hooks JSX rendering not working properly
- Firebase deploy routes not working as they did with npm run (React)
- nested api calls when iterating over data
- Not all state attributes populating from firebase databse in react app
- How could I structure this React Native Section List implementation
- Material UI: how to switch from sidebar to bottom navigation when using grid
- Why I got undefined variable when I dispatch gettAll data - ReactJs hooks redux Crud
- Multiple SetState on async data fetching data from Firestore causing performance-hampering blinking effect
- REACT: TypeError: Cannot read property 'productID' of undefined
- How to deploy react app to Github pages for personal page
- how to make custom radiobutton like this in reactjs
- Can't include pagination with React in API request
- Is it possible to get value right after api call?
- React-Router - Link to the same page not triggering page unMount
- componentDidUpdate() doesn't seem to get called after actual re-rendering occurs
- Uncaught Error: Element type is invalid: expected a string
- How to fill in a table in react with an array of objects?
- How can I merge 2 modals into 1 using components with React / Redux?
- How do I make this React Core UI Tab Pane component work?
- Configure production environment in a create-react-app(SyntaxError: Unexpected token < in JSON at position 0)