Skip to content

juiceboxes/react-starter-app

Repository files navigation

juiceboxes/react-starter-app

React.js starter app

Getting Started

You must be using a version of Node > 7.0

git clone git@github.com:juiceboxes/react-starter-app.git

Build app

  1. npm install

  2. npm run start

    • starts webpack bundler and serves the files with webpack dev server
  3. Navigate to localhost:8002

Testing

  • Travis is used to test the build for this code.
    • npm run test will run linters and tests
    • test folder is configured

Technologies

Webpack

Webpack.config.js

This file exports an object with the configuration for webpack and webpack dev server.

React

  • High-Order Component

  • Smart/Presentational Components

    • Smart components have access to the redux state
    • Presentational components do not have access to the redux state
    • Smart Components === insights-frontend/app/js/states
    • Presentational Components === insights-frontend/app/js/components
  • State and lifecycle within class components

    • article contains:
      • Adding Lifecycle Methods to a Class
      • Adding Local State to a Class
      • State Updates May Be Asynchronous
      • State Updates are Merged

Helper function

React-redux

React-router-dom

When setting up the routes, the page content is wrapped with a .page__{pageName} class, applied to the #root ID that is determined by the rootClass in the Routes.js which lets you easily reference the page in the styling.

  • BrowserRouter
    • A <Router> that uses the HTML5 history API (pushState, replaceState and the popstate event) to keep your UI in sync with the URL
  • Route
  • Switch
    • Renders the first child <Route> or <Redirect> that matches the location.
  • Redirect
    • navigate to a new location
  • withRouter
    • passes updated match, location, and history props to the wrapped component whenever it renders