From the course: The Freelance Stack: Real Project with Next.js and Strapi
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Functionality subscribe to newsletter component - Next.js Tutorial
From the course: The Freelance Stack: Real Project with Next.js and Strapi
Functionality subscribe to newsletter component
We'll now take care of the functionality of this component. So, so far, we've used the useClient keyword here, even though we didn't actually need it. But now we're going to bring in useState, because what we need to be able to do is track what the user is inputting in this input component right here. So, what we're going to say is, we first say we're first going to have some state here, which we name e-mail and then set e-mail and useState is going to be set first to an empty string. Now for us to track what the user is actually inputting we first have to say well this input right here needs to have the value of e-mail and we also want to have an onChange function with which we can update exactly this state, right, this e-mail here. So we're going to create a new function in here that I'm going to call onChange because we've already named it here basically. And what's coming into onChange will be this event, right? Anytime somebody types something in the input we're going to receive…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Highlight Article JSX structure8m 8s
-
(Locked)
Styling: Highlight article6m 42s
-
(Locked)
Subscribe to newsletter JSX structure4m 34s
-
(Locked)
Styling: Subscribe to newsletter component9m 57s
-
(Locked)
Functionality subscribe to newsletter component6m 15s
-
(Locked)
Featured items component JSX structure11m 36s
-
(Locked)
Styling featured items component12m 19s
-
(Locked)
-
-
-
-