Skip to content

hoangnm/react-app-structure

Repository files navigation

react-app-structure

React web app structure.

Table of Contents

Install

Install yarn and run

yarn

Usage

Running the web app

yarn start

Developer Guide

  1. React: https://reactjs.org/.
  2. React-Router: https://reacttraining.com/react-router/web/example/basic.
  3. Redux: http://redux.js.org/.
  4. Saga: https://github.com/redux-saga/redux-saga.
  5. Reselect: https://github.com/reactjs/reselect.
  6. CSS - Inline styles with https://github.com/Khan/aphrodite.

Linting and Code Formatting Conventions

ESLint with eslint-config-airbnb.

Inspecting and Debugging

We can use two tools:

Chrome Debugger

Use extension for redux, https://github.com/zalmoxisus/redux-devtools-extension.

Reactotron

https://github.com/infinitered/reactotron.

Developer Tools

Storybook

Helps to build components independently: https://storybook.js.org/basics/quick-start-guide/.

Blueprints

Generate a new dumb component / HOC Component (that has access to state)/ redux duck (actions/reducers) by using redux-cli

npm install -g redux-cli

After installing, we can:

  • generate duck file
redux g duck <name>
  • generate container (smart) component
redux g smart <name>
  • generate dumb component
redux g dumb <name>

References

App Architecture

  • Container components (containers folder): connect with redux store and dispatch actions to sagas or reducers.
  • Dumb components (components folder): mainly describe UI, base on props, which are passed from container.
  • Reducers (store/reducers folder): Receive actions (from sagas or containers) and return new state.
  • Sagas (store/sagas folder): Listen actions from containers, handle side-effect (example: call remote api) and dispatch actions back to reducers.
  • Selectors with Reselect (store/selectors folder): compute derived data from state, allowing Redux to store the minimal possible state (from Reselect documentation) and memorize data, avoid containers to re-render needlessly.

TODO

  • update storybook.
  • flow type checking.

About

react skeleton

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published