Giter Club home page Giter Club logo

react-es6-starter's Introduction

react-es6-starter

A simple starter template for a React ES6 web app, companion to Getting Started with React & ES6.

Build Status Coverage Status

This project and article demonstrates:

  1. How to get started with ES6 code using a combination of Webpack and Babel
  2. How to handle ESX transpilation
  3. A simple method to support unit tests for your application
  4. Code Coverage for ES6

Check the code out, npm install and then npm start!

git clone https://github.com/dwmkerr/react-es6-starter.git
cd react-es6-starter
npm install
npm start

You can run the tests with:

npm test

Notes

Heroku

The repo will deploy to Heroku as-is with no modifitications. To keep the repository as clean as possible I've left out the Procfile required to run with Heroku locally. However, if you need to do this, just add a file in the root of the repository named Procfile with the contents:

web: ./node_modules/.bin/http-server

Further Reading

Some useful material:

Testing

  1. How to easily test React components with Karma and Webpack
  2. How to implement testing and code coverage on React with Karma, Babel and Webpack

General

  1. https://medium.com/@gunnarlium/es6-code-coverage-with-babel-jspm-karma-jasmine-and-istanbul-2c1918c5bb23
  2. http://kentor.me/posts/testing-react-and-flux-applications-with-karma-and-webpack/
  3. https://github.com/binarykitchen/gulp-jest-iojs/issues/1
  4. http://www.hammerlab.org/2015/02/14/testing-react-web-apps-with-mocha/

Potential Improvements

[ ] Document setting up test-debug. [ ] Support ES6 and sourcemaps in the debug code. [ ] Build everything to build rather than having a build and public folder. [ ] Use the Webpack dev server, support live reloading and hot reloading. [ ] Show some component state in the React code and some component testing. [ ] Open the browser after test-debug starts. [ ] Show how a build command might differ from a start command (may be out of scope). [ ] Use global mutable state for react, leading into the next in the series (React + Redux).

react-es6-starter's People

Contributors

dwmkerr avatar knsv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-es6-starter's Issues

update for Babel 6

Instead of just downloading this repo (which works great), I tried following your blog post in order to learn the process better. However in the blog, you don't specify Babel 5.x (even though you do in the package.json in this repo), so I ended up with a broken stack because I just installed the latest Babel (6+).

Support Babel@6 is a pretty simple change: https://medium.com/@malyw/how-to-update-babel-5-x-6-x-d828c230ec53#.7xxg7di94. If you're willing to accept it, I can create a pull request.

use ReactDOM instead of deprecated React.render

Since your blog post, it looks like React has separated out react-dom and deprecated React.render. These are the console errors I get:

Warning: React.render is deprecated. Please use ReactDOM.render from require('react-dom') instead.warning @ bundle.js:9378newFn @ bundle.js:26937(anonymous function) @ bundle.js:7414__webpack_require__ @ bundle.js:20(anonymous function) @ bundle.js:48__webpack_require__ @ bundle.js:20(anonymous function) @ bundle.js:40(anonymous function) @ bundle.js:43
bundle.js:9378 Warning: render(): Rendering components directly into document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try rendering into a container element created for your app.

The fix is just npm install --save react-dom and add change app.js to the following:

import React from 'react';
import ReactDOM from 'react-dom';  
import Home from './home/home';

ReactDOM.render(<Home />, document.body);

I can create a PR if you want. That still doesn't fix the warning for rendering to the body, but that's a separate issue.

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.