Blessing we do around editing.
A stream is making sure that inside of stream edit Whenever on Samit right here gets called with our
brand new title and description inside that form Bally's object rather than doing that console log.
We need to call some appropriate action creator.
Now recall that we already wired up the edit stream action creator to our stream edit form.
So inside of an submit all we really have to do here is call that action creator before we do I want
to very quickly pull up the edit stream action creator itself and just get a quick reminder on how it
works.
So if I open up my actions index not just file heres at it Stream right here.
So take a look at the different arguments.
The first argument is actually going to be the ID of the stream that we are trying to edit.
Remember when we make a request to our API the expectation if we are following restful conventions is
that we are going to make a put request to the API specifically to the route streams slash and then
the idea of the stream that we're trying to update.
So that's why we need to pass and the idea of the stream we're trying to update as the first argument
right here.
And then the second argument is going to be the new changed values that we want to update our stream
with.
Remember that prior to the last video we accidentally had a form belly's object that had the ID and
the user id of the stream as well.
Foreign values is really just supposed to be the change properties of the stream.
And so that's why the last video we had that long discussion around making sure that we only set up
title and description inside the form so form values should contain only title and description.
All right.
So let's go back over to our component and we're going to make sure that we call it with our ID and
form formalities.
So back inside the stream at it I'm going to remove the console log we have in there and then I will
call this stop Propp start at it Stream.
Now is the first argument we need to pass in our ID.
Remember we've already got access to our id very easily as this prop's not matched up pro-ams ID will
say easily because.
Yeah that's a pretty long little thing right there but whatever.
So we're going to pass on that idea first.
And then as the second argument we're going to pass in the change form value.
So it's going to be the form values object right there.
Right.
And that is pretty much it.
Now before we test this I want to point out one thing very quickly that's going to save us just a little
bit of time.
Remember after we submit a form the expectation is that we're going to make a request and then hopefully
give our users some feedback.
Essentially you don't tell them that something just changed or maybe transition them or navigate them
to some other page inside of our application.
We already went over this topic in great detail which creates dream up year remember with great stream
we said that after we made our request and dispatch in action we were then going to forcibly navigate
our user back to the main list of streams.
So I think that we should probably definitely do the same thing with added stream as well.
So back inside of it it Stream after we make our request successfully after we then dispatch an action
I'm then going to call history push
and forcibly navigate our user back to the root route of our application write their history push.
OK let's save this and then we'll flip back over to the browser and we'll do a quick test.
So going to first refresh the page just in case and then I'll make a change to how about just my description
right here.
I'll say this stream is about refactoring.
And then I will submit that now as soon as I submit it you'll notice that I get this dream is about
refactoring right here.
But you'll also notice that I've now lost my edit and my delete buttons over here as well which is pretty
darn interesting.
So the input or the update took hold.
That's good.
But the fact that I don't see edit and delete any more even though that is a string that was created
by me is a little bit disconcerting.
So let's take a quick pause right here.
When we come back the next section will figure out why edit and delete decided to up and disappear.