You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each of these elements would be separate Components, and you would define a file for each. Component files are always named after the component they contain: `App.js`, `Header.js`, `Logo.js`, `NavBar.js`, `NavLink.js`, `Content.js`, `Card.js`, and `Footer.js`.
14
+
Each of these elements would be separate Components, and you would define a file for each. Component files are always named after the component they contain: `App.js`, `Header.js`, `Logo.js`, `NavBar.js`, `NavLink.js`, `Content.js`, `Card.js`, and `Footer.js`.
15
15
16
16
Components can be nested. That is one Component can be the child of another Component. Rendering the parent would render the child. The components from the list above might be nested in this way:
17
17
@@ -104,19 +104,19 @@ You may have noticed that `React`, the variable imported at the top of the page,
104
104
105
105
JSX has rules of syntax that come with it.
106
106
107
-
**Rule** JSX must always have a top level node.
107
+
**Rule** JSX must always have a top level node.
108
108
109
109
For example, the code below produces an error:
110
110
111
-
```JSX
111
+
```js
112
112
// Error! Sibling nodes
113
113
<h1>Hello</h1>
114
114
<p>World</p>
115
115
```
116
116
117
117
Whereas this code will not produce an error:
118
118
119
-
```JSX
119
+
```js
120
120
// Good! has a single top level element
121
121
<div>
122
122
<h1>Hello</h1>
@@ -208,20 +208,20 @@ Since the Component doesn't have any child Components you can use a self-closing
208
208
209
209
This is another **rule** of the JSX Language. Empty tags can be written as a single tag ending with `/`.
210
210
211
-
**Challenge:** If you're not running your React project do it now and check out your work in the browser.
211
+
**Challenge:** If you're not running your React project do it now and check out your work in the browser.
212
212
213
-
- Using the terminal navigate to your project directory.
213
+
- Using the terminal navigate to your project directory.
214
214
- In terminal run: `yarn start`bash
215
215
216
-
You should only see the page title at the top, it's the only thing your App component is rendering at the moment.
216
+
You should only see the page title at the top, it's the only thing your App component is rendering at the moment.
217
217
218
-
**Challenge:** Add the logo to the page.
218
+
**Challenge:** Add the logo to the page.
219
219
220
-
To do this you'll need to add a new tag. Add an `<img />` tag. Notice the tag ends with a `/`.
220
+
To do this you'll need to add a new tag. Add an `<img />` tag. Notice the tag ends with a `/`.
Copy file name to clipboardexpand all lines: P02-Building-Content/content.md
+21-21
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,7 @@ function POPOSSpace() {
116
116
exportdefaultPOPOSSpace
117
117
```
118
118
119
-
There are a few things missing here but you will revisit this shortly and pick up those details. You used the React Logo as a place holder for images that will come in the future.
119
+
There are a few things missing here but you will revisit this shortly and pick up those details. You used the React Logo as a place holder for images that will come in the future.
120
120
121
121
For now import `POPOSSpace` into to your `POPOSList`.
122
122
@@ -158,7 +158,7 @@ Also, notice how your project is structured.
158
158
- POPOSSpace
159
159
- POPOSSpace
160
160
161
-
If you imagine your project as tree structure you can see that you have components nested within components similar to the HTML DOM.
161
+
If you imagine your project as tree structure you can see that you have components nested within components similar to the HTML DOM.
@@ -292,11 +292,11 @@ function POPOSSpace(props) {
292
292
const { name, image, address } = props
293
293
return (
294
294
<div>
295
-
<img
296
-
src={`${process.env.PUBLIC_URL}images/${image}`}
297
-
width="300"
298
-
height="300"
299
-
alt="Hello"
295
+
<img
296
+
src={`${process.env.PUBLIC_URL}images/${image}`}
297
+
width="300"
298
+
height="300"
299
+
alt="Hello"
300
300
/>
301
301
<h1>{name}</h1>
302
302
<div>{address}</div>
@@ -338,19 +338,19 @@ function POPOSList() {
338
338
339
339
The values for props are defined as attributes. The names here must match the names used within the component! Earlier you used: name, image, and address. These are the names that must be used here.
340
340
341
-
Compare the two components:
341
+
Compare the two components:
342
342
343
343
344
344
345
-
```JSX
345
+
```js
346
346
// In POPOSList.js
347
347
<POPOSSpace
348
348
name="50 California Street"// name
349
349
address="50 California St."// address
350
350
image="50-california-st.jpg"// image
351
351
/>
352
352
```
353
-
```JSX
353
+
```js
354
354
// In POPOSSpace.js
355
355
functionPOPOSSpace(props) {
356
356
// The attributes above set the values of these properties
@@ -372,7 +372,7 @@ You can assign props as key value pairs defined in JSX like attributes in HTML.
372
372
373
373
You can access props inside a component from the `props` object which is passed as a parameter, like so:
0 commit comments