Code Monkey home page Code Monkey logo

react-redux-asyn-sample's Introduction

React Redux Async Sample

Overview

Welcome to this sample of ToDo list using modern technologies. Always thinking on scaling projects, here is the first version of an example of how I set a SPA project based on those Features:

  • Composition of a webpage
  • Managing state of UI
  • Component (isolated) styles
  • Responsive design - avoiding SASS
  • Asynchronous API calls - CRUD
  • Keeping same UI state and server data
  • Routing
  • Error handling

Stack

Getting Started

Install

yarn install

Make sure you are running the API at 8080 port otherwise a 404 will be shown. Take a look the repo here.

yarn start

Then open http://localhost:3000/ to see your app.

Walking through

Folder structure

react-redux-asyn-sample/
└── src/
	├── api/
	│	├── Todo/
	│  	│	└── TodosAPI.js
	│	├── ...
	├── components/
	│	├── List/
	│	│	└── ListItem.js
	│	├── ...
	├── containers/
	│	├── Todo/
	│	│	└── Form.js
	│	│	└── List.js
	│	│	└── TodoFeatures.js
	│	│	└── TodoSagas.js
	│	├── ...
	├── pages/
	│	├── App/
	│	│	└── App.js
	│	├── Error/
	│	│	└── Error404.js
	│	├── Layout/
	│	│	└── Layout.js
	├── styles/
	│	└── mixins.js
	│	└── variables.js
   	└── index.js
   	└── store.js

Each file is inside of its Feature folder.

api/

API calls should be here, all methods must return a Promise in order to be resolved by redux-saga, this is why I'm using Axios.

components/

Only rendering components here, none of them should be conected to store nor dispatch actions to replace state. They must recieve props and then return JSX content. Action dispatchers must be passed in as a props as well.

containers/

All components should be conected to store and get props and actions dispatchers form there. They are calling render components and passing them props. Here you must create files with the Sagas and Redux features such as reducers and actions

Sagas

File with the postfix Sagas -> TodoSagas.js

Here you define the Generators methods to call async methods and then update the state to the UI.

Features

File with the postfix Features -> TodoFeatures.js

All Redux stuff, you must export actions names, actions creators, default state and the reducer as default.

pages/

Each global component will be rendered by Router, usually must have store connection to get global states such as isLoading some request to server.

Future features

Still working on:

  • Theming
  • Grids
  • Animations
  • User Session states

react-redux-asyn-sample's People

Contributors

larrotta69 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.