1 00:00:01,410 --> 00:00:07,650 So again we can delete a post but when it gets deleted we should really navigate the user automatically 2 00:00:07,650 --> 00:00:09,500 back to the index. 3 00:00:09,540 --> 00:00:15,000 We've really already done this before almost this exact same action inside of the post component. 4 00:00:15,000 --> 00:00:24,390 So remember when we created our form we grab the contacts we got our router and then when a user successfully 5 00:00:24,390 --> 00:00:31,020 created the post we navigated navigated them back to the index route right here. 6 00:00:31,020 --> 00:00:36,430 I encourage you to pause a video at this point and go ahead and try to implement this feature by yourself 7 00:00:36,430 --> 00:00:36,450 . 8 00:00:36,450 --> 00:00:39,820 It's going to look very similar to what we already did right here. 9 00:00:39,870 --> 00:00:42,720 So if you want to give it a shot yourself feel free to pause right now. 10 00:00:42,750 --> 00:00:46,340 Otherwise we're just going to dive right into it. 11 00:00:47,630 --> 00:00:48,150 OK. 12 00:00:48,210 --> 00:00:51,750 So step one at the top. 13 00:00:51,780 --> 00:00:59,830 We're going to import the product types again to make use inside of our context types assignment. 14 00:01:00,060 --> 00:01:08,970 So we'll say static contex types that's going to be an object and we specifically want access to the 15 00:01:08,970 --> 00:01:14,780 router piece of context which is the product types dot object. 16 00:01:14,890 --> 00:01:19,180 Remember that comes from the re-act import up here. 17 00:01:19,530 --> 00:01:22,270 So this gives us access to the router. 18 00:01:23,280 --> 00:01:29,550 Now we want to make sure that we navigate back to the index only after the post is successfully deleted 19 00:01:30,300 --> 00:01:37,130 because our action creator contains a promise on the payload property or action created right here. 20 00:01:37,130 --> 00:01:39,120 We return a promise as well. 21 00:01:39,490 --> 00:01:42,820 And so we can chain on with a dot then. 22 00:01:43,450 --> 00:01:49,240 And inside there we'll just define our function and very straight forward. 23 00:01:49,280 --> 00:01:55,490 We'll say this Tom context router pushed back to the index. 24 00:01:56,280 --> 00:01:56,880 That's it. 25 00:01:56,880 --> 00:01:58,500 Nice and simple. 26 00:01:58,650 --> 00:01:59,650 I'm going to save this. 27 00:01:59,670 --> 00:02:02,220 And let's go ahead and give it a shot. 28 00:02:02,940 --> 00:02:11,150 Refresh the page delete the posts and we get navigated automatically back to our post index page. 29 00:02:11,160 --> 00:02:15,390 I've got a duplicate blog post in here right here so let's go ahead and clean this one up. 30 00:02:15,810 --> 00:02:18,310 So we'll delete it and it gets cleaned up. 31 00:02:18,360 --> 00:02:19,490 Nice. 32 00:02:20,120 --> 00:02:20,480 OK. 33 00:02:20,490 --> 00:02:22,090 This is looking pretty darned good. 34 00:02:22,350 --> 00:02:24,810 Let's go ahead and wrap up in the next section