Answer the question
In order to leave comments, you need to log in
How to rewrite the value of another in one reducer?
There is an action:
export const SET_SSR_PROPS = 'SET_SSR_PROPS';
export const setSsrProps = response => ({
type: SET_SSR_PROPS,
payload: response
});
import { createReducer } from '../storeUtils';
import { SET_SSR_PROPS } from '../actions/ssrActions';
const initialState = {};
const setSsrProps = (state, action) => ({
...action.payload
});
export default createReducer(initialState, {
[SET_SSR_PROPS]: setSsrProps
});
import { combineReducers } from 'redux';
import orderData from './orderReducer';
import prevSsrProps from './ssrReducer';
const rootReducer = combineReducers({
orderData,
prevSsrProps
});
export default rootReducer;
console.log(store.orderData); <--------- данные из редюсера orderData orderData !== this.props.prevSsrProps
setSsrProps(this.props.prevSsrProps); <----------заменит прошлые даннные в store.orderData на this.props.prevSsrProps
console.log(store.orderData); <--------- данные из редюсера orderData orderData === this.props.prevSsrProps
Answer the question
In order to leave comments, you need to log in
Handle this action in orderData and do what you need there. And the prevSsrProps reducer is not needed at all.
The store does not have a setState method , what you want cannot be done in one action. But you can process the action in each of your reducers and replace the part of the store for which it is responsible.
Well, either through crutches and bicycles to recreate the whole story in general, but this is a bad decision.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question