6. ReactJS - Redux Thunk
❖ Allows you to write action creators that return a function instead of an
action.
❖ Used to delay the dispatch of an action
❖ or to dispatch only if a certain condition is met
Package name: redux-thunk
Github: https://github.com/gaearon/redux-thunk
8. ReactJS - Implement middleware to Store
With middleware - method #1
With middleware - method #2
9. ReactJS - Implement middleware to Store
With single middleware
With multiple middleware
10. ReactJS - Redux Thunk
Normal action Thunk action Thunk with conditional dispatch
11. ReactJS - HTTP Clients
fetch axios
Github: https://github.com/mzabriskie/axiosGithub: https://github.com/github/fetch
Get JSON content
Send POST data
Get JSON content
Send POST data
12. ReactJS - HTTP Clients
Benefits of Axios over Fetch
# Feature Axios Fetch
1 Allow data transforming before request is made YES NO
2 Interceptors: Alter request or response YES NO
3 XSRF protection YES NO
4 Allow aborting a request YES NO
5 Request timeout support YES NO
6 Safari support YES With Polyfill
7 Upload progress support YES NO
16. ReactJS - Redux API
❖ redux-thunk itself doesn’t implement any HTTP Client
❖ Generate actions and reducers for making AJAX calls to API endpoints
❖ Github: https://github.com/lexich/redux-api