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
- Prevent triggering onMouseOut event when hover over children
- How to invoke Axios synchronously in React?
- Ag grid prevents access to current value of React state variable
- Link card area that contains a button
- How to get header from SSR response in Next.js
- MUI createTheme is not properly passing theme to MUI components
- Why does it give an error 'searchInput' of undefined
- How to keep webcam video centred when the height is 100% of the screen and the window is resized
- React - Refreshing Save Counter
- replace string text with html tag using regex
- how can I solve this params errors in react
- How to set value for the checkbox in ReactJS
- Testing React PropTypes with sinon
- react-big-calendar ERROR: Invalid prop `slotStart` of type `date` supplied to `Popup`, expected `number`
- When to update state based on previous state in useState hook in React/Typescript
- Export data returned by 'fetch' from a separate .js file in React
- React direct to a "thank you" page after submitting a form
- React generated button on my form keeps refreshing the page
- Gatsby Stripe Checkout - multiple quantities
- Account for null values when mapping an array ES6
- I have a graphql query. How can I manage my 'title' useState with it? I'd like that the title would be in the query instead of "Bad boys" to send
- Problem twice click on submit handler in React JS
- MUI Swipeable Drawer but let some part be always visible
- Formik checkbox not showing tick when added in a map function
- How to pass Generic Type to component imported with Next.js Dynamic?
- setState is not merging the values
- How properly setup react-router-dom in Home Route?
- How can i display an image from mongodb in binary with reactjs
- Changing image source property of a child with dangerously set innerhtml parent attribute in React
- Media query not working in React