I have an auto-suggest component, which displays search results. On clicking a result, I am triggering an action SEARCH_RESULT_CLICKED
which in turn invokes two sagas.
Saga 1, takes the text
of the result, and triggers an action ITEM_SUMMARY_FETCHED
with payload as
{ text: ... }
which displays it in a component, say B that implements a reducer for ITEM_SUMMARY_FETCHED
.
Saga 2, takes the id
of the result, and makes an API call. Once the result is fetched, it triggers ITEM_SUMMARY_FETCHED
with payload as
{ description : ... }
The component B is expected to display, the text and description. of the selected result, the reducer is somewhat like this :
case 'ITEM_SUMMARY_FETCHED':
return {
...state.itemdetails,
...action.summary,
};
I was hoping that the properties will get merged, but it does not do so. When Saga 2 triggers the action, state
is undefined
. Consequently, the value of text gets removed and only the description is shown.
Can anyone help me with where I might be going wrong ?