How to Use Initial Values in Redux Form
Hi and welcome back to the course. So we have this problem that's occurring whenever we login to the component or the application and we hit edit. When we hit edit it's not displaying any of our information until we hit edit again.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

So this is a really simple fix all we need to do is go into this file newsletterEditForm.js and go to the redux form and add another configuration option put a comma here and say enable Reinitialize set it to true.

newsletterEditForm.js

editNewsletterForm = reduxForm({
    form: "editnewsletter",
    endableREinitialize: true
})(EditNewsletterForm);

So all we are doing is adding these 28 characters, you'll see down here is 28 selected.

large

What we're doing here is we're adding this in and we're setting it to true and it will basically reload the form once we get initial values. So let's go to Google Chrome let's login and let's hit this edit button, we can now see that we're getting items in here.

large

All right in the next video, I want to solve two problems with our images you'll see that the images displaying weird here like we can't see it, it's just like an empty image.

large

And when we hit edit we're not displaying an image here as well.

large

So I'll show you how to do those both in the next video it's going to take a little bit, or a tiny bit of refactoring, barely any at all, it's really simple. We just need to add in the ROOT_URL in front of our imageUrl.

So let's go ahead and commit our code.

Terminal

git status
git add .
git commit -m "redux form reinitialize option"

Okay, I'll see you in the next video.

Resources

Source code