Giter Site home page Giter Site logo

react-bp's Introduction

React BoilerPlate

GitHub last commit Build Status Coverage Status GitHub repo size in bytes license Heroku Staging

Folder Structure

Client

Assets

File assets used by client, eg images. Webpack config will copy to /dist or convert to base64 string if <10,000 bytes

import React from 'react';
import myImage from '../../assets/myImage.png';

const ImgComponent = () => <img src={myImage} />;

Components

Components => Simple React components not concerned by state, used by containers and scenes. Most styling will be here.

// scr/client/components/Message/index.js
import React from 'react';
import styles from './styles.scss';

const SimpleComponent = ({ message }) => <p className={styles.message}>{message}</p>;

Containers

Containers => linking Components to state and dispatch, used by containers and scenes.

// scr/client/containers/HelloMessage/index.js
import Message from '../../components/Message';
import { connect } from 'react-redux';
import { getGreeterMessage } from '../../store/greeter/selectors';

const mapStateToProps = state => ({ message: getGreeterMessage(state) });

const HelloMessage = connect(mapStateToProps)(Message);

export default HelloMessage;

Scenes

Scenes => combining containers and components together to make a page. Routes will generally point here.

// scr/client/scenes/Welcome/index.js
import HelloButton from '../../containers/HelloButton';
import HelloMessage from '../../containers/HelloMessage';
import React from 'react';

const Welcome = () => (
  <div>
    <HelloMessage />
    <HelloButton />
  </div>
);

export default Welcome;

Routes

Routes are rendered from configuration objects. Any additional object properties will be passed to the rendered component.

// src/client/routes/content.js
import { Home, Welcome } from '../loadables';

const content = [
  {
    component: Home,
    exact: true,
    path: '/',
  },
  {
    component: Welcome,
    exact: true,
    path: '/welcome',
  },
];

export default content;

Store

Configure actions and reducers for global store.

// src/client/store/greeter/types.js
export const SAY_HELLO = 'SAY_HELLO';

// src/client/store/greeter/actions.js
import { SAY_HELLO } from './types';
import { createAction } from 'redux-actions';

export const sayHello = createAction(SAY_HELLO);

//src/client/store/greeter/reducers.js
export const sayHelloReducer = (state, action) => {
  state.message = action.payload;
};

// src/client/store/greeter/selectors.js
import { createSelector } from '@acemarke/redux-starter-kit';

export const getGreeterMessage = createSelector(['greeter.message']);

// src/client/store/greeter/index.js
import { SAY_HELLO } from './types';
import { sayHelloReducer } from './reducers';
import { createReducer } from '@acemarke/redux-starter-kit';

export const greeter = createReducer(greeterInitialState, {
  [SAY_HELLO]: sayHelloReducer,
});

Libraries

Development Libraries

Development libraries

Client Libraries

Client libraries

Server Libraries

Server libraries

react-bp's People

Watchers

James Cloos avatar Matt Cuneo 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.