Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davezuko/react-redux-starter-kit
Get started with React, Redux, and React-Router.
https://github.com/davezuko/react-redux-starter-kit
Last synced: about 1 month ago
JSON representation
Get started with React, Redux, and React-Router.
- Host: GitHub
- URL: https://github.com/davezuko/react-redux-starter-kit
- Owner: dvdzkwsk
- License: mit
- Archived: true
- Created: 2015-06-24T18:38:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-03T17:30:08.000Z (over 6 years ago)
- Last Synced: 2024-10-29T12:57:57.330Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 1.13 MB
- Stars: 10,285
- Watchers: 303
- Forks: 2,199
- Open Issues: 130
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-components - react-redux-starter-kit - Get started with React, Redux, and React-Router!. (Code Design / Boilerplate)
- awesome - react-redux-starter-kit - Get started with React, Redux, and React-Router. (JavaScript)
- awesome-react-components-all - react-redux-starter-kit - Get started with React, Redux, and React-Router!. (Uncategorized / Uncategorized)
- awesome-seed - react-redux-starter-kit - Get started with React, Redux, and React-Router! (Seed List / React)
- awesome-list - react-redux-starter-kit - Get started with React, Redux, and React-Router!. (Code Design / Boilerplate)
README
# Deprecation Warning
This project was started at the advent of the Redux ecosystem, and was intended to help users get up and running quickly. Since then, tooling and best practices have evolved tremendously. In order to get the most modern experience possible, I recommend checking out something like [create-react-app](https://github.com/facebookincubator/create-react-app) which is supported by many core React and Redux developers.
You are welcome to use this project if it is a better fit for your needs, but if you are brand new to the ecosystem I highly recommend checking out something that has received more recent updates.
Thank you to everyone who made this project possible over the past year(s).
# React Redux Starter Kit
[![Build Status](https://travis-ci.org/davezuko/react-redux-starter-kit.svg?branch=master)](https://travis-ci.org/davezuko/react-redux-starter-kit?branch=master)
[![dependencies](https://david-dm.org/davezuko/react-redux-starter-kit.svg)](https://david-dm.org/davezuko/react-redux-starter-kit)
[![devDependency Status](https://david-dm.org/davezuko/react-redux-starter-kit/dev-status.svg)](https://david-dm.org/davezuko/react-redux-starter-kit#info=devDependencies)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)This starter kit is designed to get you up and running with a bunch of awesome front-end technologies.
The primary goal of this project is to provide a stable foundation upon which to build modern web appliications. Its purpose is not to dictate your project structure or to demonstrate a complete real-world application, but to provide a set of tools intended to make front-end development robust, easy, and, most importantly, fun. Check out the full feature list below!
Finally, This project wouldn't be possible without the help of our many contributors. What you see today is the product of hundreds changes made to keep up with an ever-evolving ecosystem. [Thank you](#thank-you) for all of your help.
## Table of Contents
1. [Requirements](#requirements)
1. [Installation](#getting-started)
1. [Running the Project](#running-the-project)
1. [Project Structure](#project-structure)
1. [Live Development](#local-development)
* [Hot Reloading](#hot-reloading)
* [Redux DevTools](#redux-devtools)
1. [Routing](#routing)
1. [Testing](#testing)
* [dirty-chai](#dirty-chai)
1. [Building for Production](#building-for-production)
1. [Deployment](#deployment)
1. [Thank You](#thank-you)## Requirements
* node `^5.0.0`
* yarn `^0.23.0` or npm `^3.0.0`## Installation
After confirming that your environment meets the above [requirements](#requirements), you can create a new project based on `react-redux-starter-kit` by doing the following:
```bash
$ git clone https://github.com/davezuko/react-redux-starter-kit.git
$ cd
```When that's done, install the project dependencies. It is recommended that you use [Yarn](https://yarnpkg.com/) for deterministic dependency management, but `npm install` will suffice.
```bash
$ yarn # Install project dependencies (or `npm install`)
```## Running the Project
After completing the [installation](#installation) step, you're ready to start the project!
```bash
$ 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 ` |Description|
|-------------------|-----------|
|`start` |Serves your app at `localhost:3000`|
|`build` |Builds the application to ./dist|
|`test` |Runs unit tests with Karma. See [testing](#testing)|
|`test:watch` |Runs `test` in watch mode to re-run tests when changed|
|`lint` |[Lints](http://stackoverflow.com/questions/8503559/what-is-linting) the project for potential errors|
|`lint:fix` |Lints the project and [fixes all correctable errors](http://eslint.org/docs/user-guide/command-line-interface.html#fix)|## Project Structure
The project structure presented in this boilerplate is **fractal**, where functionality is grouped primarily by feature rather than file type. This structure is only meant to serve as a guide, it is by no means prescriptive. That said, it aims to represent generally accepted guidelines and patterns for building scalable applications. If you wish to read more about this pattern, please check out this [awesome writeup](https://github.com/davezuko/react-redux-starter-kit/wiki/Fractal-Project-Structure) by [Justin Greenberg](https://github.com/justingreenberg).
```
.
├── build # All build-related code
├── public # Static public assets (not imported anywhere in source code)
├── server # Express application that provides webpack middleware
│ └── main.js # Server application entry point
├── src # Application source code
│ ├── index.html # Main HTML page container for app
│ ├── main.js # Application bootstrap and rendering
│ ├── normalize.js # Browser normalization and polyfills
│ ├── components # Global Reusable Components
│ ├── containers # Global Reusable Container Components
│ ├── layouts # Components that dictate major page structure
│ │ └── PageLayout # Global application layout in which to render routes
│ ├── routes # Main route definitions and async split points
│ │ ├── index.js # Bootstrap main application routes with store
│ │ ├── Home # Fractal route
│ │ │ ├── index.js # Route definitions and async split points
│ │ │ ├── assets # Assets required to render components
│ │ │ ├── components # Presentational React Components
│ │ │ └── routes ** # Fractal sub-routes (** optional)
│ │ └── Counter # Fractal route
│ │ ├── index.js # Counter route definition
│ │ ├── container # Connect components to actions and store
│ │ ├── modules # Collections of reducers/constants/actions
│ │ └── routes ** # Fractal sub-routes (** optional)
│ ├── store # Redux-specific pieces
│ │ ├── createStore.js # Create and instrument redux store
│ │ └── reducers.js # Reducer registry and injection
│ └── styles # Application-wide styles (generally settings)
└── 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](https://webpack.github.io/docs/hot-module-replacement.html) capabilities, where code updates can be injected to the application while it's running, no full reload required. Here's how it works:
* For **JavaScript** modules, a code change will trigger the application to re-render from the top of the tree. **Global state is preserved (i.e. redux), but any local component state is reset**. This differs from React Hot Loader, but we've found that performing a full re-render helps avoid subtle bugs caused by RHL patching.
* For **Sass**, any change will update the styles in realtime, no additional configuration or reload needed.
### Redux DevTools
**We recommend using the [Redux DevTools Chrome Extension](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd).**
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:
```bash
yarn add --dev redux-devtools redux-devtools-log-monitor redux-devtools-dock-monitor
```Then follow the [manual integration walkthrough](https://github.com/gaearon/redux-devtools/blob/master/docs/Walkthrough.md).
## Routing
We use `react-router` [route definitions](https://github.com/ReactTraining/react-router/blob/v3/docs/API.md#plainroute) (`<route>/index.js`) to define units of logic within our application. See the [project structure](#project-structure) section for more information.## Testing
To add a unit test, create a `.spec.js` file anywhere inside of `./tests`. Karma and webpack will automatically find these files, and Mocha and Chai will be available within your test without the need to import them. Here are a few important plugins and packages available to you during testing:### dirty-chai
Some of the assertions available from [chai](chaijs.com) use [magical getters](http://chaijs.com/api/bdd/#method_true). These are problematic for a few reasons:
1) If you mistype a property name (e.g. `expect(false).to.be.tru`) then the expression evaluates to undefined, the magical getter on the `true` is never run, and so your test silently passes.
2) By default, linters don't understand them and therefore mark them as unused expressions, which can be annoying.[Dirty Chai](https://github.com/prodatakey/dirty-chai) fixes this by converting these getters into callable functions. This way, if mistype an assertion, our attempt to invoke it will throw due to the property being undefined.
```js
// This silently passes because the getter on `true` is never invoked!
it('should be true', () => {
expect(false).to.be.tru // evalutes to undefined :(
})// Much better! Our assertion is invalid, so it throws rather than implicitly passing.
it('should be true', () => {
expect(false).to.be.tru() // `tru` is not defined!
})
```## Building for Production
## Deployment
Out of the box, this starter kit is deployable by serving the `./dist` folder generated by `yarn build`. This project does not concern itself with the details of server-side rendering or API structure, since that demands a more opinionated structure that makes it difficult to extend the starter kit. The simplest deployment strategy is a [static deployment](#static-deployments).
### Static Deployments
Serve the application with a web server such as nginx by pointing it at your `./dist` folder. Make sure to direct incoming route requests to the root `./dist/index.html` file so that the client application will be loaded; react-router will take care of the rest. If you are unsure of how to do this, you might find [this documentation](https://github.com/reactjs/react-router/blob/master/docs/guides/Histories.md#configuring-your-server) helpful. The Express server that comes with the starter kit is able to be extended to serve as an API and more, but is not required for a static deployment.
## Thank You
This project wouldn't be possible without help from the community, so I'd like to highlight some of its biggest contributors. Thank you all for your hard work, you've made my life a lot easier and taught me a lot in the process.
* [Justin Greenberg](https://github.com/justingreenberg) - For all of your PR's, getting us to Babel 6, and constant work improving our patterns.
* [Roman Pearah](https://github.com/neverfox) - For your bug reports, help in triaging issues, and PR contributions.
* [Spencer Dixon](https://github.com/SpencerCDixon) - For your creation of [redux-cli](https://github.com/SpencerCDixon/redux-cli).
* [Jonas Matser](https://github.com/mtsr) - For your help in triaging issues and unending support in our Gitter channel.And to everyone else who has contributed, even if you are not listed here your work is appreciated.