Coder Social home page Coder Social logo

marinsokol / react-redux-flow-starter-kit Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 371 KB

Simple kit for everyone to start developing react applications with Flow and Redux

License: MIT License

JavaScript 94.63% HTML 2.44% CSS 2.93%
redux flow redux-devtools redux-observable epics react react-redux react-router eslint webpack

react-redux-flow-starter-kit's Introduction

React / Redux (with Flow) Starter Kit

Table of Contents

  1. Requirements
  2. Installation
  3. Running the Project
  4. Project Structure
  5. Live development
  6. Async
  7. Type Checking
  8. Deployment

Requirements

  • node ^5.0.0
  • yarn ^0.23.0 or npm ^3.0.0

Installation

$ git clone https://github.com/marinsokol/react-redux-flow-starter-kit.git <my-project-name>
$ cd <my-project-name>

When that's done, install the project dependencies. It is recommended that you use Yarn for deterministic dependency management, but npm install will suffice.

$ yarn  # Install project dependencies (or `npm install`)

Running the Project

$ yarn start  # Start the development server (or `npm start`)

While developing, you will probably rely mostly on yarn start; however, there are additional scripts at your disposal:

yarn <script> Description
start Serves your app at localhost:3050
build Builds the application to ./public/dist
test Runs unit tests with Jest. See testing
lint Lints the project for potential errors
lint:fix Lints the project and fixes all correctable errors
flow Runs Flow type checker. See Type Checking

Project Structure

.
├── public                 # Static public folder containing build application
│   ├── dist                 # Folder containing production build js for application
│   └── index.html           # Main HTML page container for app
├── server                 # Express application that provides webpack middleware
│   └── app.js               # Server application entry point
├── src                    # Application source code
│   ├── app.js               # Application bootstrap and rendering
│   ├── components           # Global Reusable Components
│   ├── constants          # Constants important for whole application
│   │   └── actionTypes.js   # Declaration for all action types in application  
│   ├── epics              # Async side effects in Redux 
│   │   └── index.js         # Combines all epics for application
│   ├── layouts            # Components that dictate major page structure
│   │   └── index.js         # Global application layout in which to render routes          
│   ├── reducers           # Reducer registry and injection
│   │   └── index.js              
│   ├── routes               # Main route definitions and async split points
│   │   ├── index.js         # Bootstrap main application routes with store
│   │   ├── Home             # Fractal route
│   │   │   ├── index.js     # Route container
│   │   │   ├── components   # Presentational React Components
│   │   └── Game             # Fractal route
│   │       ├── index.js     # Game route definition (injects custom reducer to store)
│   │       ├── actions      # Actions for game route
│   │       ├── components   # Presentational React Components
│   │       ├── container    # Connect components to actions and store
│   │       ├── reducers     # Reducer for game route
│   │       └── types        # Types for game route
│   ├── store             # Create and instrument redux store  
│   │   └── index.js           
│   └── types             # Custom type for Flow
└── tests                    # Unit tests

Live Development

Hot Reloading

Hot reloading is enabled by default when the application is running in development mode (yarn start). This feature is implemented with webpack's Hot Module Replacement capabilities, where code updates can be injected to the application while it's running, no full reload required.

Redux DevTools

We recommend using the Redux DevTools Chrome Extension. Using the chrome extension allows your monitors to run on a separate thread and affords better performance and functionality. It comes with several of the most popular monitors, is easy to configure, filters actions, and doesn't require installing any packages in your project.

However, it's easy to bundle these developer tools locally should you choose to do so. First, grab the packages from npm:

yarn add --dev redux-devtools redux-devtools-log-monitor redux-devtools-dock-monitor

Then follow the manual integration walkthrough.

Async

This project uses redux-observable for async actions and creating side effects. Redux-observable is using 'epics' for that actions. Epics are functiona which takes a stream of actions and returns a stream of actions. Actions in, actions out. Like this:

const actionEpic = (action$) => action$;

const pingEpic = action$ =>
  action$.filter(action => action.type === 'PING')
    .delay(1000) 
    .mapTo({ type: 'PONG' });

// later you dispatch only 'PING' action

Your reducers will receive the original PING action and PONG action after 1s.

Type Checking

This project uses Flow static type checker. Flow settings are defined in .flowconfig. By default, Flow ignores __test__, config, node_modules, public, server floders and checking ALL other .js files. If You are using VS Code, You can install vscode-flow-ide to get live type checking and errors. You can also type check by running:

$ yarn run flow

Deployment

Out of the box, this starter kit is deployable by serving the ./public folder generated by yarn build. This project does not concern itself with the details of server-side rendering or API structure. This makes it easy do deploy to service like Firebase Hosting

react-redux-flow-starter-kit's People

Contributors

marinsokol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.