Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,070 --> 00:00:04,700
So for this NewMeetup component
2
00:00:04,700 --> 00:00:08,660
we again create a function here a component function
3
00:00:08,660 --> 00:00:11,270
like the NewMeetupPage function.
4
00:00:11,270 --> 00:00:14,570
And of course, as before we need to export this
5
00:00:14,570 --> 00:00:17,580
so that NextJS is able to find this
6
00:00:17,580 --> 00:00:20,890
and then we can render our content here.
7
00:00:20,890 --> 00:00:23,050
Now our content in this case
8
00:00:23,050 --> 00:00:25,850
should be the NewMeetupForum component
9
00:00:25,850 --> 00:00:29,860
which I prepared in advance, which renders a form
10
00:00:29,860 --> 00:00:33,560
with some controls, with some styles attached
11
00:00:33,560 --> 00:00:36,840
using CSS modules here for styling.
12
00:00:36,840 --> 00:00:39,690
I'll come back to that in a second, that is supported
13
00:00:39,690 --> 00:00:43,510
by NextJS out of the box, which is really convenient.
14
00:00:43,510 --> 00:00:46,290
And then here we get that data.
15
00:00:46,290 --> 00:00:49,900
We extract that data, the user entered, with help offer Refs
16
00:00:49,900 --> 00:00:51,940
which has a built in React feature
17
00:00:51,940 --> 00:00:54,370
has nothing to do with NextJS.
18
00:00:54,370 --> 00:00:58,630
And then we basically call a function which we expect to get
19
00:00:58,630 --> 00:01:01,570
on the onAddMeetup prop.
20
00:01:01,570 --> 00:01:03,050
And to that function
21
00:01:03,050 --> 00:01:05,360
we then pass the collected meetup data.
22
00:01:05,360 --> 00:01:08,173
So this object with all the collected data.
23
00:01:09,310 --> 00:01:14,130
And hence now in this newMeetup index JS file here
24
00:01:14,130 --> 00:01:18,647
we can use that component and we can import newMeetupForm
25
00:01:20,260 --> 00:01:24,960
from going up two levels to leave the pages folder diving
26
00:01:24,960 --> 00:01:28,453
into the components folder, Meetups, and then newMeetupForm.
27
00:01:30,150 --> 00:01:32,110
And then we can return newMeetupForm
28
00:01:33,880 --> 00:01:36,563
this component like this if we want to.
29
00:01:37,790 --> 00:01:40,520
Now as I just mentioned, in this component
30
00:01:40,520 --> 00:01:44,580
we do expect that there will be a onAddMeetup prop
31
00:01:44,580 --> 00:01:46,860
which holds a function that we can call.
32
00:01:46,860 --> 00:01:48,320
And hence we might want to prepare
33
00:01:48,320 --> 00:01:50,550
this function here as well.
34
00:01:50,550 --> 00:01:53,950
We can add our addMeetupHandler function
35
00:01:53,950 --> 00:01:57,500
or however you want to name it and then pass a pointer
36
00:01:57,500 --> 00:02:02,500
after this function to the onAddMeetup prop a pointer
37
00:02:02,630 --> 00:02:05,580
and not the result of executing it.
38
00:02:05,580 --> 00:02:08,430
So no parentheses here, because this function
39
00:02:08,430 --> 00:02:12,650
should be executed eventually from inside that component,
40
00:02:12,650 --> 00:02:15,723
when the form is submitted as it turns out.
41
00:02:16,570 --> 00:02:19,733
Here, we then get our enteredMeetupData.
42
00:02:21,148 --> 00:02:23,570
And we can, for example, for the moment
43
00:02:23,570 --> 00:02:25,923
simply log this to the console.
44
00:02:27,180 --> 00:02:30,090
And with that out of the way, if we go back again
45
00:02:30,090 --> 00:02:34,100
we can visit localhost3000/newMeetup
46
00:02:34,100 --> 00:02:36,790
and we see this form again,
47
00:02:36,790 --> 00:02:40,010
not to final styling a bit too wide,
48
00:02:40,010 --> 00:02:41,970
but we see the form.
49
00:02:41,970 --> 00:02:44,440
And if I opened the developer tools here
50
00:02:44,440 --> 00:02:49,440
and I enter test and test, or here, we actually need a URL.
51
00:02:51,200 --> 00:02:54,140
So I will just quickly grab that URL
52
00:02:54,140 --> 00:02:57,700
which I set up for my dummy data, this URL
53
00:02:57,700 --> 00:03:01,710
I'll grab that and use this here Test Address.
54
00:03:01,710 --> 00:03:03,260
And This is a test.
55
00:03:03,260 --> 00:03:06,650
If we enter this data and we click Add Meetup
56
00:03:06,650 --> 00:03:09,370
we see this object logged to the console.
57
00:03:09,370 --> 00:03:11,630
So handling form submission works.
58
00:03:11,630 --> 00:03:14,020
Obviously we're not doing anything with that data.
59
00:03:14,020 --> 00:03:16,470
At this point, we're not navigating away
60
00:03:16,470 --> 00:03:19,590
and we are going to do all these things later
61
00:03:19,590 --> 00:03:22,430
but this again just shows us how we can use pages
62
00:03:22,430 --> 00:03:27,290
and also mix regular React components into those pages.
63
00:03:27,290 --> 00:03:30,110
And then, with that, that's a great start
64
00:03:30,110 --> 00:03:33,130
but now we're already facing a couple of issues here.
65
00:03:33,130 --> 00:03:35,900
We've got a lot of missing functionality, of course.
66
00:03:35,900 --> 00:03:38,970
And for example, we also have no way
67
00:03:38,970 --> 00:03:41,710
for navigating between pages
68
00:03:41,710 --> 00:03:45,880
and we have no general layout around our pages.
69
00:03:45,880 --> 00:03:48,190
Every page takes up the entire width.
70
00:03:48,190 --> 00:03:50,120
We get no header above them.
71
00:03:50,120 --> 00:03:53,053
And that is probably something we want to change.
5708
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.