Skip to content

Commit 7fb48a5

Browse files
authored
Merge pull request #86 from arvish-codal/4_June
React - Setting up props type with TS.
2 parents 12365ad + cdbe0d1 commit 7fb48a5

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NOTES/react-notes-2.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,7 @@ Once the command is successfully executed, we can see the project structure,
207207

208208
> And the App.tsx contains our app component which is the root component.
209209
> Components are defined in a `.tsx` file and not in a `.js` or `.jsx` file.
210+
211+
Video - 95
212+
213+
> A look at few basic prop types we're likely to use when creating a component with TypeScript.

react-typescript/react-typescript-demo/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import './App.css';
2+
import { Greet } from './components/Greet';
23

34
function App() {
45
return (
56
<div className="App">
6-
7+
<Greet name='arvish' />
78
</div>
89
);
910
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type GreetProps = {
2+
name: string
3+
}
4+
5+
export const Greet = (props: GreetProps) => {
6+
return (
7+
<div>
8+
<h2>Welcome {props.name}! You have 10 unread messages</h2>
9+
</div>
10+
)
11+
}

0 commit comments

Comments
 (0)