Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,320 --> 00:00:05,120
Now that we're able to render a couple
2
00:00:05,120 --> 00:00:06,400
of meetups there,
3
00:00:06,400 --> 00:00:10,470
with help of our MeetupList and MeetupItem components,
4
00:00:10,470 --> 00:00:14,460
it would of course be good if those meetups would not come
5
00:00:14,460 --> 00:00:19,410
from our dummy_data source, but from an actual server.
6
00:00:19,410 --> 00:00:21,890
And they should actually end up
7
00:00:21,890 --> 00:00:24,490
on that server because we created them
8
00:00:24,490 --> 00:00:26,840
on the add new meetup page.
9
00:00:26,840 --> 00:00:28,300
After all, that's the goal
10
00:00:28,300 --> 00:00:32,640
of this demo application that on this add page,
11
00:00:32,640 --> 00:00:37,640
we have a nice little form for entering data about a meetup,
12
00:00:37,710 --> 00:00:40,620
so entering this kind of data in the end
13
00:00:40,620 --> 00:00:45,210
and then that data should be sent to some server
14
00:00:45,210 --> 00:00:49,900
to some backend where it's then also stored in a database
15
00:00:49,900 --> 00:00:54,040
so that then it can be fetched and loaded in all meetups.
16
00:00:54,040 --> 00:00:56,440
By doing that, meetups that are added here,
17
00:00:56,440 --> 00:01:00,800
could be shared with all visitors from all over the world,
18
00:01:00,800 --> 00:01:04,870
since data is stored in a database on some backend server,
19
00:01:04,870 --> 00:01:09,430
not just in our browser and the data would also be there
20
00:01:09,430 --> 00:01:12,120
if we reload the page.
21
00:01:12,120 --> 00:01:14,230
If we just store data in memory,
22
00:01:14,230 --> 00:01:17,040
any data is lost if we reload the page,
23
00:01:17,040 --> 00:01:20,160
because the JavaScript application restarts
24
00:01:20,160 --> 00:01:22,633
and the previous state is lost.
25
00:01:23,590 --> 00:01:27,670
And therefore the first step is to add this form
26
00:01:27,670 --> 00:01:29,800
to this add new meetup page.
27
00:01:29,800 --> 00:01:31,810
So that then in a second step,
28
00:01:31,810 --> 00:01:36,250
we can gather the entered data and send it to a server.
29
00:01:36,250 --> 00:01:40,260
And for this will work in this NewMeetup.js file
30
00:01:40,260 --> 00:01:43,763
which is the file that should render this meetup form.
31
00:01:45,200 --> 00:01:48,470
So in here, I'll actually also add a section
32
00:01:48,470 --> 00:01:52,980
and the h1 title of add new meetup,
33
00:01:52,980 --> 00:01:54,360
but then below that,
34
00:01:54,360 --> 00:01:56,720
I wanna output the meetup form
35
00:01:56,720 --> 00:01:59,080
which I will actually create
36
00:01:59,080 --> 00:02:01,580
and store in a separate file
37
00:02:01,580 --> 00:02:05,743
to again keep this NewMeetupPage clean.
38
00:02:06,600 --> 00:02:09,360
Now a good folder would be the meetups folder
39
00:02:09,360 --> 00:02:11,080
in the component folder.
40
00:02:11,080 --> 00:02:14,350
And therefore, in here, we can add a new file,
41
00:02:14,350 --> 00:02:19,350
the NewMeetupForm file, for example, NewMeetupForm.js.
42
00:02:21,270 --> 00:02:26,070
Now attached again, you find a styling file for this file,
43
00:02:26,070 --> 00:02:29,810
the NewMeetupForm.module.css
44
00:02:29,810 --> 00:02:31,460
which you can just download
45
00:02:31,460 --> 00:02:34,560
and add next to this JavaScript file
46
00:02:34,560 --> 00:02:38,260
so that you have some styles, which I prepared for you.
47
00:02:38,260 --> 00:02:41,620
And in the NewMeetupForm.js file,
48
00:02:41,620 --> 00:02:43,720
we now create another function,
49
00:02:43,720 --> 00:02:46,990
because we're going to create another component.
50
00:02:46,990 --> 00:02:51,100
The NewMeetupForm function and component
51
00:02:51,100 --> 00:02:55,000
which just as before is exported here
52
00:02:55,000 --> 00:02:58,013
to make it availble outside of this file.
53
00:02:59,660 --> 00:03:02,070
In the NewMeetupPage component,
54
00:03:02,070 --> 00:03:03,780
below this title,
55
00:03:03,780 --> 00:03:07,690
we can then already add that NewMeetupForm.
56
00:03:07,690 --> 00:03:11,303
Make sure you also add the appropriate import.
57
00:03:12,750 --> 00:03:17,490
Now, once you did add it back into NewMeetupForm.js file,
58
00:03:17,490 --> 00:03:21,430
we can start with outputting the JSX code for the form.
59
00:03:21,430 --> 00:03:24,780
Now I wanna actually wrap this form again
60
00:03:24,780 --> 00:03:28,210
in this card to give it to this card look
61
00:03:28,210 --> 00:03:29,620
and that's why I created
62
00:03:29,620 --> 00:03:32,160
that separate card component before.
63
00:03:32,160 --> 00:03:35,333
So that we can now reuse that component.
64
00:03:36,330 --> 00:03:39,080
So now, besides using the card component
65
00:03:39,080 --> 00:03:42,350
in the MeetupItem component, we can also use it
66
00:03:42,350 --> 00:03:46,630
in the NewMeetupForm simply by using it here
67
00:03:46,630 --> 00:03:48,490
and of course by importing it,
68
00:03:48,490 --> 00:03:51,380
you always need to import what you use
69
00:03:51,380 --> 00:03:56,313
in a file from the UI folder and the card file.
70
00:03:57,660 --> 00:04:02,200
Now card will then be wrapped around the actual HTML form
71
00:04:02,200 --> 00:04:05,700
that we'll create and then we'll well populate
72
00:04:05,700 --> 00:04:07,873
that form with various inputs.
73
00:04:08,780 --> 00:04:12,040
Now I did provide that css file for the form.
74
00:04:12,040 --> 00:04:14,530
So that's also already import classes
75
00:04:14,530 --> 00:04:19,529
from ./NewMeetupForm.module.css
76
00:04:20,540 --> 00:04:22,730
to have these scoped styles.
77
00:04:22,730 --> 00:04:26,540
And we can start assigning classes on that form element
78
00:04:26,540 --> 00:04:30,543
where you should assign the form class like this.
79
00:04:32,580 --> 00:04:34,070
Now inside of this form,
80
00:04:34,070 --> 00:04:36,700
you can of course structure this however you want,
81
00:04:36,700 --> 00:04:40,070
but to fit the styles which I provided to you,
82
00:04:40,070 --> 00:04:45,070
I'll add a div with a class of classes control.
83
00:04:45,530 --> 00:04:49,050
And in that div I wanna have a label where we say,
84
00:04:49,050 --> 00:04:51,120
Meetup Title, for example,
85
00:04:51,120 --> 00:04:53,793
for the first input we're going to add.
86
00:04:54,770 --> 00:04:58,690
Now that input is added here and is of type text.
87
00:04:58,690 --> 00:05:00,310
It should be required,
88
00:05:00,310 --> 00:05:03,373
so that we have that in-browser validation.
89
00:05:04,240 --> 00:05:09,240
And I will give it an ID of title and then self close it
90
00:05:10,770 --> 00:05:12,560
and now connect this label
91
00:05:12,560 --> 00:05:15,130
to this input by adding the for attribute,
92
00:05:15,130 --> 00:05:20,130
but just as class, for is a keyword in JavaScript
93
00:05:20,530 --> 00:05:23,260
and therefore the actual property name
94
00:05:23,260 --> 00:05:26,350
for setting this, for value or
95
00:05:26,350 --> 00:05:31,260
for setting this attribute here is htmlFor.
96
00:05:31,260 --> 00:05:34,560
So I add htmlFor as a prop
97
00:05:34,560 --> 00:05:38,350
and that's another exception besides classname
98
00:05:38,350 --> 00:05:42,340
where you use a attribute name that deviates
99
00:05:42,340 --> 00:05:45,190
from the regular HTML attribute name.
100
00:05:45,190 --> 00:05:48,520
It's basically the only other important exception,
101
00:05:48,520 --> 00:05:51,150
besides classname, which you have to memorize.
102
00:05:51,150 --> 00:05:54,670
And then we point at title here.
103
00:05:54,670 --> 00:05:56,570
And this simply connects this label
104
00:05:56,570 --> 00:05:59,360
to this title for screen readers
105
00:05:59,360 --> 00:06:01,743
and other assistive technologies.
106
00:06:02,770 --> 00:06:05,920
Now we have this input with this label here
107
00:06:05,920 --> 00:06:09,320
and we can now repeat this entire control div,
108
00:06:09,320 --> 00:06:14,320
multiple times to also render a label
109
00:06:14,320 --> 00:06:18,750
for the meetup image and maybe use an id
110
00:06:18,750 --> 00:06:23,110
of image here and change this to type url.
111
00:06:23,110 --> 00:06:28,110
Since the image set here should actually be a url pointing
112
00:06:28,500 --> 00:06:29,710
at an image.
113
00:06:29,710 --> 00:06:33,720
If you're interested in uploading files with react,
114
00:06:33,720 --> 00:06:37,140
that is not really that much of a react task,
115
00:06:37,140 --> 00:06:39,590
but mostly a backend server task.
116
00:06:39,590 --> 00:06:41,790
And hence I discuss file uploads
117
00:06:41,790 --> 00:06:44,400
in my node JS course, for example,
118
00:06:44,400 --> 00:06:48,230
but to learn how to make file uploads work with react,
119
00:06:48,230 --> 00:06:51,470
I also have a resource attached, a tutorial
120
00:06:51,470 --> 00:06:53,660
which you can take a closer look at
121
00:06:53,660 --> 00:06:57,280
to learn how to upload files with react.
122
00:06:57,280 --> 00:06:59,750
Here we'll not upload files.
123
00:06:59,750 --> 00:07:04,110
We'll just insert the URL of a existing image
124
00:07:04,110 --> 00:07:06,693
which already exists on some server.
125
00:07:08,710 --> 00:07:13,380
Then we can, let's replicate this div again
126
00:07:13,380 --> 00:07:17,920
for our address here, let's say
127
00:07:17,920 --> 00:07:20,550
and the id could be address.
128
00:07:20,550 --> 00:07:23,430
And here we'll again, just have some plain text
129
00:07:23,430 --> 00:07:27,560
as an input type and there after,
130
00:07:27,560 --> 00:07:30,170
I wanna have one more control
131
00:07:31,110 --> 00:07:34,150
which is the actual description of the meetup.
132
00:07:34,150 --> 00:07:38,500
And hence we could use description as an id,
133
00:07:38,500 --> 00:07:41,410
but here I'll actually not render an input,
134
00:07:41,410 --> 00:07:44,130
but instead a text area,
135
00:07:44,130 --> 00:07:46,973
which is another default HTML element.
136
00:07:47,987 --> 00:07:51,404
It'll still get that id description here.
137
00:07:52,573 --> 00:07:56,360
And it will also still get the required attribute
138
00:07:56,360 --> 00:08:00,020
for adding this in-browser validation.
139
00:08:00,020 --> 00:08:02,480
And I'll set rows to five.
140
00:08:02,480 --> 00:08:04,680
That's another default attribute,
141
00:08:04,680 --> 00:08:06,663
which we can add to text areas.
142
00:08:08,100 --> 00:08:10,000
Now last but not least, below that,
143
00:08:10,000 --> 00:08:14,680
I'll add another div with a class name of classes, actions.
144
00:08:14,680 --> 00:08:18,390
And in there I wanna have the button that submits the form.
145
00:08:18,390 --> 00:08:21,590
So here we can add a button where we say Add Meetup.
146
00:08:21,590 --> 00:08:24,550
And that button will then submit that form.
147
00:08:24,550 --> 00:08:27,610
That's how HTML in the browser works.
148
00:08:27,610 --> 00:08:29,440
If you have a button in a form,
149
00:08:29,440 --> 00:08:32,809
a button which is not of type button.
150
00:08:32,809 --> 00:08:34,860
So if you have a regular button like this,
151
00:08:34,860 --> 00:08:38,620
then such a button will submit that form.
152
00:08:38,620 --> 00:08:41,663
And we can later listen to that submit event.
153
00:08:42,850 --> 00:08:45,863
And this should be actions as a class here.
154
00:08:46,900 --> 00:08:48,870
And with that, if you save that file,
155
00:08:48,870 --> 00:08:52,420
you should see this form on the screen.
156
00:08:52,420 --> 00:08:55,713
Now the form doesn't work yet, but it's there.
12396
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.