React Redux and Redux Thunk (Fetching data Async) setup written in Typescript (React + Redux + Redux Thunk + Typescript)
react-redux-thunk-typescript ├── scripts # Standalone scripts for dev uses └── src # Project source dir │── components # Contains all the reusable components │ │── lib # Contains wrapper class files of npm lib │ └── redux # Redux code (All logic lies here) │ │── reducers │ │ └── globals.ts # Globals reducer │ └── store.ts # Root store file (Which is used as param for provider) │ │── App.tsx # Contains app component │── App.css │── index.tsx # App component is wrapped with Provider from react redux in this file └── index.css
- Create React App (Out of the box setup for quickstart)
- Typescript (For static typechecking)
- Redux Thunk (For async calls)
- This project contains two jsx components Header and Footer to demonstrate accessing/connecting redux store to two independent components.
- Header component has two buttons which is conditionally rendered based on the Redux globals reducer store value
isLoggedIn
and has on click listener methodlogin
andlogout
two reducer Methods which on click dispatches the similar named reducer methods in reducer that changes redux store state for globals reducer variableisLoggedIn
totrue
iflogin
called elsefalse
iflogout
called.