8. React+Thunk+ActionCreator+Reducer
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.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «8. React+Thunk+ActionCreator+Reducer», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.