Reactjs and Ajax
React is a library for a View part. It works with DOM. I work with React/Redux, because Redux gives good help for handling with states. When developers work with a View part, them need to get data from server. Ajax is technology for Javascript and server data exchange. React haven’t tools for Ajax.
So… We can work with vanilla Ajax, or we can download Ajax module. For React are two better Ajax modules: Axios and Fetch. I work with Fetch. It is very simple and has polyfill for older browsers.
I wrote ir previous article about React and Redux. When we work with React/Redux and Fetch (or Axios) we have to mutate actions.
In example i call dispatch in action file. Fetch sends data to server and gets response. Promise calls dispatch and sends data to receivePermission function. If we work with Fetch we have to know — Ajax is asynchronous technology and need work differently.