Step 10 - React tutorial: Model Class State with TypeScript interfaces

preview_player
Показать описание
### Step 10 in the "React, TypeScript, and TDD" tutorial

Make a very simple class component with local counter state, then make an interface for that state.

00:00 - Start
00:23 - Start with a failing test
00:39 - Add an interface to model the state
00:53 - Add this as the second interface in the generic (props and state)
00:57 - Component constructor, including state initializing
01:38 - Change the TSX to display that state (the count)
01:48 - The tests now pass
01:57 - Allow passing in a prop for counter starting value, starting with a test
02:02 - "Fail faster" thanks to TypeScript
02:20 - Optional starting value in interface
02:23 - Provide default prop value
02:30 - The state gets its starting value from this optional prop
03:12 - Type guard for complaint about possible missing value

More on this tutorial step:
The rest of this "React, TypeScript, and TDD" tutorial:
See tips, tutorials, and more in the PyCharm Guide:
Рекомендации по теме
welcome to shbcf.ru