Reputation: 373
i want to be able to show status of the action.type in the component when i trigger it : it's for showing if an action has been passed succesfully or not(when catch triggered). Have you an idea please ?
Upvotes: 0
Views: 262
Reputation: 9
If you want to access it through your console , and have access to the
action inside your component, you could simply trigger a console.log(action.type) inside it.
Upvotes: 0
Reputation: 131
*emphasized text*someAction.js
when a action will be called dispatch the follwing line.
const someActionToBeCalledFromComponent = (parameters) => async(dispatch) => {
try {
dispatch({
type: SOME_ACTION_HAS_CALLED_SUCCESSFULLY
});
//do your stufs
} catch (error) {
//do your stufs
}
}
<!-- begin snippet: js hide: false console: true babel: false -->
})
//do your stuffs .
}
catch(error) {
//do your stufs here.
}
}
<!-- end snippet -->
Now in reducer catch the action type
const someReducer = (state, action) => {
switch (action.type) {
case: SOME_ACTION_HAS_CALLED_SUCCESSFULLY
return {
status_of_the_action_type: true
}
//other cases goes here
default: return state
}
Now keep the reducer in a state and use it in typical way of redux.
Upvotes: 1