8. React+Thunk+ActionCreator+Reducer

Published: 01 January 1970
on channel: It-Patsan-US
55
7

Hi guys, glad to see you again. Our last lessons were hard, with topics broken up into several classes. It may be difficult for your mind to wrap up all this information, but no worries -eventually you will do it. Today we will repeat what we have learned. The delete method will help us with this. We should delete users.
At first, if you know what to do, start from tag. WE should create a button that can delete.
Look here, in each line we will insert a button to be able to delete it.
Lets go.
Of course we have to use the id - because without it we won't know what to delete.
The button is ready.
Now we take all the logic upstairs. We are creating a function.

Nothing new for us inside. We have to dispatch the Thunk Creator. Inside we pass the Id of the user we want to remove. It's done
Let's go create Thunk.

And then we get to the request to the server. Of course, we go there and see how to do it.

We should go to AXIOS, and there type out a new request. Draw attention, we are passing here Id.

We use a Template Strings, if this is difficult for you to understand, write please a comment below and I will create a video on this topic.
In the variable res we put the result of API calls. Let's console log.
Friends! We are working with fake API, and we can't delete the user. I mean we have to return an array of users from the server with one of them deleted. But JSONplaceholder, can't do that. So we will do everything ourselves with the Filter method.

We create an ACtion creator and type it. Dive into Reducer.

Congratulations! We did it, and now we can see our result. Finally we should push our project to GitHub, and check how it works in Heroku.
Ok.
You can see my code in GitHub under this video. Subscribe to my channel and invite all your friends. Now we have a modern stack. Next time we will continue to create new requests. Keep in mind, that the man who couldn’t be a programmer has not been born yet.


On this page of the site you can watch the video online 8. React+Thunk+ActionCreator+Reducer with a duration of hours minute second in good quality, which was uploaded by the user It-Patsan-US 01 January 1970, share the link with friends and acquaintances, this video has already been watched 55 times on youtube and it was liked by 7 viewers. Enjoy your viewing!