Are there any official naming convention on naming action creators and action.types
Looking over tutorials the theme of the action creator and action type is to name the action type pretty much one to one with action creator.
To use an example lets say we have an application fetching blog posts
The tutorial (top rated Udemy tutorial) used the following naming convention with asynchronous action creator:
export const fetchPosts = () => async dispatch => {
const response = await postsAPI.get('/posts');
dispatch({type: 'FETCH_POSTS', payload: response.data});
};
However, wouldnt it make more sense to name the action objects more precisely (to signify success or failure) to what is being dispatched. Rather than matching action creator function name with action type, along the lines of:
export const fetchPosts = () => async dispatch => {
const response = await postsAPI.get('/posts');
if (response.status === 200) {
dispatch({type: 'FETCHED_POSTS', payload: response.data});
} else {
dispatch({type: 'FAILED_TO_FETCH_POSTS', payload: response});
}
};