All right.
I think you know exactly what we have to do because I've repeated it three times now.
Let's make sure that create an edit pass down some props to our blog post form to come out customize
what happens when it is shown inside of either those.
So first start off with create because I think we've got a pretty good idea of what's going on inside
their OKAY.
SO I GOT TO GO BACK TO MY create screen.
Here it is right here.
So we need to formulate some set of props that we're gonna pass into add a blog post form the first
prop I think we should add in.
And remember I'm just gonna make up the name of these different props off the top of my head.
So I think a reasonable name for a prop to call that we're going to eventually pass like this on submit
callback to would be simply on submit it's going to pass on submit a function.
And the idea here is that anytime that the user submits the form I want to have my blog post form invoke
this on submit prop so inside of here I'll put in a body to the Arrow function.
So that's just gonna be the extra set of curly braces and then we're going to do the exact same thing
that we did when all of our logic was inside of create screen.
We're going to call add blog post we're going to pass in the new title and content that the user just
provided.
And we're also going to make sure that we pass in a callback to navigate back to the index screen using
that navigation prop.
Now there is one little catch here.
I just said two seconds ago we're gonna call at blog post with the new title and content but inside
of create screen we don't know what the edited title and content are.
So I think that we need to put in an additional requirement to our on submit function.
We need to make sure that whenever blog post form calls on submit it has to pass in the new updated
title and content or excuse me not updated because this is the create screen.
But whatever title and content the user typed into the form.
OK.
So inside of this callback we'll now call add blog post.
We can pass in the title and content that was provided to our callback function right here and then
we can put in our third argument which remember is going to be a callback that will execute our navigation
dot navigate function and go back to our index screen.
So I'll put in my callback function that we'll call navigation dot navigate and we'll go back to index.
OK.
So now let's save this.
We'll go into a blog post form and we're going to make sure that any time a user taps on that submit
button we call on submit with a new title and content.
So inside a blog post form remember we initialize these two state variables title and content right
here.
We'll go down to our button here's the button and I'm going to add on that new prop
of on press and inside of here we're going to run our on submit callback that was passed in as a prop
2 blog post form.
And when we run this thing we're gonna make sure that we provide the title and content that the user
just entered.
So essentially our title and content state variables.
Now one quick thing I did not actually receive this on submit prop at the top of the function.
So let's make sure that we do structure on submit out of our props object to backup here.
Here's our props or our arguments I'm going a d structure out on submit like so OK so I'll save this.
And this should now work correctly for our create screen.
So once again when we show our blog post form we are saying here's a function to call anytime a user
submits the form and the expectation is that that function will be called with the title and content
that the user just entered.
So we're still at the end the day essentially running the exact same code that we were running before
when we had all of our form logic inside the create screen.
OK.
So a quick test a flip back over remember right now only the create screen should be working edit screen
is not going to work.
So going to go to create all entering a new title and some amount of content will save the post.
And there we go there's my new title it's showing up there's my randomly generated idea as well and
if I tap on that I should see my content right there underneath the new title.
Very good.
Now we've got our great screen put together.
We can start to focus once again on the edit screen so quick pause.
I'll take care of edit screen in just a moment.