Sitemap
HackerNoon.com

Elijah McClain, George Floyd, Eric Garner, Breonna Taylor, Ahmaud Arbery, Michael Brown, Oscar Grant, Atatiana Jefferson, Tamir Rice, Bettie Jones, Botham Jean

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.

Get Audrus’s stories in your inbox

Join Medium for free to get updates from this writer.

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.

--

--

Audrus
Audrus

Written by Audrus

Developer: Spring, Nodejs, Reactjs.

HackerNoon.com
HackerNoon.com

Published in HackerNoon.com

Elijah McClain, George Floyd, Eric Garner, Breonna Taylor, Ahmaud Arbery, Michael Brown, Oscar Grant, Atatiana Jefferson, Tamir Rice, Bettie Jones, Botham Jean