simple-sifu / tutorial-redux-vite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tutorial-redux-vite

Redux Architecture

Actions and Reducers

use of Index

Big Issues with Redux/React-Redux + Typescript

  • Imports between files can turn into a mess very quickly
  • Communicating types over to your components can be challenging
  • Type def files for Redux, React-Redux, and others are possibly over-engineered

In the upcoming lecture, we will be adding our searchRepositories action. You will likely see a TS error in the catch block that says Object is of type 'unknown'

There are two ways that you can resolve this for now:

Option #1

} catch (err: any) { Option #2

...

} catch (err) { if (err instanceof Error) { dispatch({ type: ActionType.SEARCH_REPOSITORIES_ERROR, payload: err.message, }); } }

About


Languages

Language:TypeScript 93.7%Language:HTML 6.3%