Best way to do async request (ajax and side effects) in ReactJs using hooks, Redux style - useReducer()

How to fetch data with React Hooks? You will mostly end-up with Robin’s blog post regarding the fecth method. But the problem using useState() is that we can’t execute any other code after fetch success. for an example:- do one fetch, if that fetch is successfull then call some JavaScript like clear the form using useState(), if fails display error message. That’s somehow difficult if we use useState(). fetch using useState() I created a codesandbox based on best practices to fetch data using hooks....

May 26, 2019 · 3 min · 556 words · M.Kumaran