Popping the First Item Off the Archive Component
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

[00:00:01] Hey welcome back to the reactor out in the sky. We got our component created and we have the data feeding into there. And this guy we're going to fix up our Archa components that cuts off the one night we are displaying here in the newsletter component. So it's pretty simple. We just have to pop this off the array basically. But we're going to take an approach that doesn't use the park method. So our newsletter our advertiser. We have to do is return archive without the first item. So all we can do is say this stack overflow post by searching remove from right. And this is the easiest way is using shift. If you ever made the ship function shifts everything to the left. So basically it will pop off the first item but it won't return it will just get rid of it. So pretty simple shift and we have our new Array right. So go to our app here and let's just say it's optional. Would say constant action. Or let's say archive of Aksenov a lot of them as just say archive shift and then we could just put archive in right here at work but since it's the same name. Yes 6 allows us to just say archive save that and let's check it out in the browser and it should work. Yeah cuts it off great but you'll notice that now display displaying the first items on this list which has seasons of Thanksgiving season Thanksgiving not happy holidays. [00:01:37][96.2]
[00:01:39] So the way we can fix that and the reason it's doing is because basically this is not copying object it's just pointing to whatever action our paywall is. And so when we're saying Archa does shift it's actually saying action not payload. So kind of like a pointer if you've ever pointers. Now the way we can actually get rid of the way we can fix it is by first declaring a latest item object so it's called this kind of the latest item to be the same thing and doing the archive by naming it the same thing let's say constant state is equal to. So basically what's happening is it's going to get the first item before we do it and then it's going to shift it and then we're going to put it all in and it should be cracked. So save it let's remove the page and see what we got. We were great. We have Happy holidays and we have our new best with the first one cut off so that's how you fix that. And that's all we're going to be doing in this God. So it's coming our code saying get ad commit. I'm going say fixed archive component. Ms. Staged removed first item from archive. Okay I'll catch the next guy. [00:01:39][0.0]
[96.2]