Skip to content

An attempt at finding best practices when putting together react, react-redux, redux-saga and a REST API

Notifications You must be signed in to change notification settings

jabberbees/react-redux-saga-rest-stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Motivation

While creating my first React single page app, I struggled to piece together a solution that would fulfill all the following requirements :

  • Use React for UI rendering only
  • Use React Router v4
  • Use React Redux for state management
  • Use Redux-Saga to manage all side effects
  • Use an abstracted, promised based REST API client
    • no dependency on HTTP client: fetch, axios, ...
    • no dependency on types: HttpResponse, ...
  • No sacrifice on testability
    • no dirty tricks
    • no singleton modules

Later on I realised that in some cases I needed to know when a saga had completed or failed so I looked for a way to have dispatched actions/sagas return a Promise.

This is exactly what redux-saga-thunk does so I added an example to show how that works.

This is what I found. Comments are very welcome.

How to use

This project was bootstrapped with Create React App.

In the project directory, run:

npm install
npm start

Open http://localhost:3000 to view it in the browser.

Inspirations

Authentication with react-router-redux 5.x and redux-saga

Using context in redux-saga

Protected routes and authentication with React Router v4

About

An attempt at finding best practices when putting together react, react-redux, redux-saga and a REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published