Grokking TypeScript
0% completed
Understanding TypeScript with React
What happens when a React component receives a prop of the wrong type? In plain JavaScript, usually nothing visible happens at first. This ProfileCard expects a number for age, and a caller passes text:
const ProfileCard = ({ name, age }) => { return ( <p> {name} is {age} years old </p> ); }; const page = <ProfileCard name="Ana" age="thirty" />;
The component renders "Ana is thirty years old", and no tool reports a problem. The fault appears later, perhaps when other code tries to calculate with age
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%