Skip to content

Commit 591fe30

Browse files
committed
Added problem/solution to 54
1 parent 4758233 commit 591fe30

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* 1. What's the difference between JSX.Element,
3+
* React.ReactNode and React.ReactElement?
4+
*
5+
* CMD-click each of them to understand the difference.
6+
*/
7+
8+
type ClickMe = React.ReactElement;
9+
type ClickMeToo = JSX.Element;
10+
type ClickMeThree = React.ReactNode;
11+
12+
/**
13+
* 2. What is the return type of this Component?
14+
*/
15+
const Component = () => {
16+
return <div>Hello world</div>;
17+
};
18+
19+
/**
20+
* 3. Fun fact - this might break on your IDE! In
21+
* TypeScript 5.0, this wouldn't work. But in TypeScript
22+
* 5.1, it DOES work.
23+
*
24+
* If it's not working for you, try making your IDE use
25+
* the 'workspace' version of TypeScript.
26+
*
27+
* https://stackoverflow.com/questions/39668731/what-typescript-version-is-visual-studio-code-using-how-to-update-it
28+
*/
29+
const Component2 = (): React.ReactNode => {
30+
return <div></div>;
31+
};
32+
33+
<>
34+
<Component2 />
35+
</>;
36+
37+
/**
38+
* 4a. Why does this component NOT error...
39+
*/
40+
const Component3 = (): React.ReactElement => {
41+
return <div></div>;
42+
};
43+
44+
<>
45+
<Component3 />
46+
</>;
47+
48+
/**
49+
* 4b. ...but this one does?
50+
*/
51+
const Component4 = (): React.ReactElement => {
52+
return "hello!";
53+
};

0 commit comments

Comments
 (0)