Transcript
00:00 So Kelly, the coworker, improved things a little bit. You could take a look at our utils that's in the shared directory of the repo. And we have this set global search params, which is called whenever we submit the form. And so if I type in cat in here and then hit Enter, that submits the form, not a full page refresh, and updates the search param.
00:19 So now we can copy and paste this and put it everywhere we want. There's not a whole lot that's special or React-specific going on in here. Feel free to delete this and rewrite it yourself if you want to play a little JavaScript golf, I guess. But the idea is we have a problem. And that problem that you are supposed to solve here
00:38 is when I hit the Back button, nothing happens. I mean, the URL gets updated because the browser's managing that state. But we are not synchronizing our state with that URL. So when the user goes forward and backward, that is firing an event that we can listen for to know, oh, the user is trying to go forward. The user is trying to go backward.
00:58 That's called the pop state event. And so your job is to add an event listener to pop state. And you're going to do this inside a use effect. So those are the steps that you need to follow. And you're going to start out with the query being dog, type in cat, hit Submit, and then hit the Back button. And if you've got that all worked out,
01:16 then you should be good to go for this part of the exercise. You've still got a bug that you might notice in here that we need to fix. And there are a couple other small problems here as well. So we're not totally done. But if you can hit the Back button and the search gets updated to remove the cat,
01:35 then you should be in a good place for this step.