File tree Expand file tree Collapse file tree 7 files changed +12
-12
lines changed
02.raw-react/02.problem.nesting
03.using-jsx/02.problem.interpolation Expand file tree Collapse file tree 7 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,12 @@ generate this DOM output:
12
12
</div >
13
13
```
14
14
15
- Hint: you can either use the ` children ` prop or additional arguments after the
15
+ Hint: You can either use the ` children ` prop or additional arguments after the
16
16
props. If you use the ` children ` prop, you will get a warning in the developer
17
17
console about needing a "key" prop. We'll get to that later.
18
18
19
- Tip, you 'll use ` createElement ` for the ` span ` elements, but to get the
19
+ Tip: You 'll use ` createElement ` for the ` span ` elements, but to get the
20
20
space between them, you'll need to use a string (` ' ' ` ) to tell React to create
21
- a [ ` textNode ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/Text )
21
+ a [ ` textNode ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/Text ) .
22
22
23
23
- [ 📜 ` createElement ` ] ( https://react.dev/reference/react/createElement#createelement )
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const children = 'Hello World'
22
22
const element = <div className = " hmmm" >how do I make this work?</div >
23
23
```
24
24
25
- 📜 The react docs for JSX are pretty good:
25
+ 📜 The React docs for JSX are pretty good:
26
26
[ Writing Markup with JSX] ( https://react.dev/learn/writing-markup-with-jsx )
27
27
28
28
Here are a few sections of particular interest for this step:
Original file line number Diff line number Diff line change 5
5
👨💼 Super, but that's definitely not the most fun way to use custom components.
6
6
In fact, we're technically not creating a custom component at all. We're just
7
7
interpolating a function call into our template. This will have interesting
8
- implications in the future with react features like state and effects.
8
+ implications in the future with React features like state and effects.
9
9
10
- Instead, let's create react elements out of this function which is what we're
10
+ Instead, let's create React elements out of this function which is what we're
11
11
going for...
Original file line number Diff line number Diff line change 2
2
3
3
<EpicVideo url = " https://www.epicreact.dev/workshops/react-fundamentals/raw-api/solution" />
4
4
5
- 👨💼 Great! While that's not really all that nicer to work with, it does get us a
6
- centimeter closer to our goal of using JSX with custom components. It's also
7
- interesting to throw a couple console logs around and see how using
5
+ 👨💼 Great! While that's not really all that much nicer to work with, it does
6
+ get us a centimeter closer to our goal of using JSX with custom components.
7
+ It's also interesting to throw a couple console logs around and see how using
8
8
` createElement ` compares to simply calling the function directly in our
9
9
JSX.
10
10
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ element = <message>Hello World</message>
17
17
And we're so close! Just like using JSX for regular ` div ` s is nicer than using
18
18
the raw ` createElement ` API, using JSX for custom components is nicer too.
19
19
Remember that it's Babel that's responsible for taking our JSX and compiling it
20
- to ` createElement ` calls. If we try `<message >Hello World</message >,
20
+ to ` createElement ` calls. If we try ` <message>Hello World</message> ` ,
21
21
here's what Babel will do:
22
22
23
23
``` tsx
Original file line number Diff line number Diff line change 6
6
"props" which is the object your component function accepts as an argument.
7
7
8
8
So now, we're going to use a ` Calculator ` component that can display an
9
- equation and it's solution, like so:
9
+ equation and its solution, like so:
10
10
11
11
``` tsx
12
12
element = <Calculator left = { 1 } operator = " +" right = { 2 } />
Original file line number Diff line number Diff line change 20
20
// 💰 you can get the result with: operations[operator](left, right)
21
21
return (
22
22
< div >
23
- { /* 🐨 render the equation and it's result here */ }
23
+ { /* 🐨 render the equation and its result here */ }
24
24
{ /* 💰 open the final version in the app if you're unsure */ }
25
25
</ div >
26
26
)
You can’t perform that action at this time.
0 commit comments