You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 9, 2021. It is now read-only.
I use this arquicteture of redux in my projects and is awesome, but how you handle the post, update or delete request.
when you do a post request and need when is complete, the state by default is false because is not dispatching any action so you don't know when the status of the post request is 'idle' or is 'success for example:
const PostandClose = () =>
{
dispatch(PostAction.PostSomething());
}
if(!PostIsLoading )
{
// do something when post end
}
so by default this if condition is true because is not loading and will trigger by default, I suggest adding an 'idle' state so we can know the post action is idle and when is 'success'
if(PostIsLoading === 'Idle')
{
// Here the action is idle and is dispatch anything
}
if(PostIsLoading === 'loading')
{
// Here the action is loading
}
if(PostIsLoading === 'Success')
{
// do something when post end
}
i don't know too much of redux so sorry if there is another way to do this easier
There is another question whit this problem, how this structure is done i think we can pass diferrent actions to the selector like this
When you click to dispatch the action make all load even if the first action on the useEffect is finished, this doesn't trigger the action but the loading doesn't work properly and render for both of them, the easy solution is to make two variables, but I think this lose sense because we pass an array and all the time will contain only one element
I use this arquicteture of redux in my projects and is awesome, but how you handle the post, update or delete request.
when you do a post request and need when is complete, the state by default is false because is not dispatching any action so you don't know when the status of the post request is 'idle' or is 'success for example:
const PostIsLoading = useSelector((state) => SelectRequesting(state, [PostAction.REQUEST_POST]));
so by default this if condition is true because is not loading and will trigger by default, I suggest adding an 'idle' state so we can know the post action is idle and when is 'success'
i don't know too much of redux so sorry if there is another way to do this easier
There is another question whit this problem, how this structure is done i think we can pass diferrent actions to the selector like this
const PostIsLoading = useSelector((state) => SelectRequesting(state, [PostAction.REQUEST_POST, PostAction_2.REQUEST_POST_2]));
this doesn't make any error but if we put a button that dispatch the second action, this makes the loading of the first action 'true', for example
When you click to dispatch the action make all load even if the first action on the useEffect is finished, this doesn't trigger the action but the loading doesn't work properly and render for both of them, the easy solution is to make two variables, but I think this lose sense because we pass an array and all the time will contain only one element
const PostIsLoading = useSelector((state) => SelectRequesting(state, [PostAction.REQUEST_POST,]));
const Post_2IsLoading = useSelector((state) => SelectRequesting(state, [PostAction_2.REQUEST_POST_2]));
The text was updated successfully, but these errors were encountered: