filmov
tv
Context API React + Typescript | useContext & useReducer Examples

Показать описание
Learn how to use the Context API with React + Typescript. This tutorial provides examples with useContext, useReducer, and custom React hooks. The React Context API is your first step towards global state management.
🚀 Become a full-stack web dev with Zero To Mastery Courses:
👇 Follow Me On Social Media:
Context API React + Typescript | useContext & useReducer Examples
(00:00) Intro
(00:08) Welcome
(00:30) Starter Code
(00:56) Extracting initial state & types
(03:52) useCounterContext hook & type
(08:27) Create Context with initial context state
(11:43) Context Provider
(16:32) useCallback
(18:07) Applying the Provider
(19:40) Custom hooks to deliver context
Corrections:
(12:42) Spreading the ...initState into the Provider parameters is not really necessary. It does help document but really just creates extra boilerplate. You can pull it in from the lexical scope of the Provider since both are defined in the same file. This will also eliminate the need to use the initState in the App component. initState will simply be passed to useCounterContext in the Provider value.
📚 Suggested Pre-requisites for this Typescript course:
📚 React Hooks tutorials:
📚 Tutorial References:
⚙ Web Dev Tools:
Was this React Hooks + Typescript useContext / Context API tutorial helpful? If so, please share. Let me know your thoughts in the comments.
#context #react #typescript
Комментарии