As we just saw our blog post form is working really well.
When we show it from the edit screen but not quite so well when we show it from the create screen and
that's entirely because the create screen does not provide this initial values prop.
So in this vacant video we're going to figure out how to solve that.
So to make sure that this initial values prop is not going to cause any issue we're going to go underneath
the definition of our blog post form right underneath my component definition and right above my style's
definition.
I'm going to write out blog post form dot default props and I'll set that equal to an object so this
default prompts property right here can be used to give our component some default property values.
In other words if we ever show this component and we choose not to pass in some given prop this object
right here will be used to fill in some default values inside of here we can put in initial values and
I'll set that to an object that has a title of empty string and content of empty string as well so now
anytime that we show our blog post form inside of our create screen we do not make use of the initial
values prop.
So instead we're going to have an initial value of that object right there so whenever we show blog
post form from the create screen initial values dot title will be an empty string and content will be
an empty string as well so that should solve our issue when the owner mentioned here is that this default
prop system is 100 percent automatic react is going to automatically check to see if our component has
this default props property on it if it does it's just going to automatically use these props for us.
So let's save this file and test this out.
It's a back inside of my emulator I'm going to try editing test post first so I'll edit it in I still
should see the appropriate title in content and if I go back over and try to create a new post I no
longer crash at the screen anymore and I can still enter in a title in content like so very good.
All right so this looks pretty good.
We've now solved that crashing issue and I think that our blog post forum in general is in a pretty
good spot.
It's not the last thing we have to do is make sure that inside of our edit screen here's edit screen
right here.
Once a user submits the changes made to a blog post we need to somehow persist that back inside of our
context object.
So let's take care of that inside the next video.