Skip to content

Instantly share code, notes, and snippets.

React.js State Explained

var React = require('react');
var $ = require('jquery');
/********************************************************
This code is to explain state mutation in React and demo
why immutable.js is a better approach
**********************************************************/
var Test = React.createClass({

Package.json

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "repository": "",
  "main": "js/app.js",
  "dependencies": {

React material-ui installation

  1. npm install material-ui --save

  2. npm install react-tap-event-plugin --save

  3. Add Google font to SCSS

@import url(https://fonts.googleapis.com/css?family=Roboto:400,300,500);
@ethan-deng
ethan-deng / babelify7.md
Last active December 2, 2015 17:23
Babelify 7 and JSX error

Babelify 7 and JSX error

First Babelify is not Babel and their version numbers doesn't match. This confuses me a lot at first.

If you run into a similar error as I did next. Try these steps to fix it.

1st, you need install

npm install --save-dev babel-preset-es2015 babel-preset-react

  • rd /S /Q node_modules

  • robocopy c:\temp node_modules /purge

  • npm cache clean

  • cd %APPDATA%\npm-cache

  • Go back to NPM 2 npm -g install npm@latest-2

NPM Install Error

To solve this issue when running "npm install", install Visual Studio 2015 and then

"File" -> "New Project" -> choose C++ template and install C++ support.

Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.

Redux-vs-Alt

A line by line comparison of Redux and Alt's implementation of Dan Abramov's Todo list example

Redux is getting hot! The trend can be seen from this Redex vs Alt NPM trend chart. However the framework of Alt + AltContainer is a much more concise and much easier to understand than Redux.

It seems Alt is not getting as much attention as Redux. There may be a few reasons for this. First, the best coding approach of Alt + AltContainer is not well documented. Second, even though Alt came out earlier than Redux but AltContainer is a few months later than Redux. Third, Dan Abramov the author of both React Hot Loader and Redux is a better known figure.

If you haven't heard of Alt, please read along and see why I think Alt is much easier than Redux. This is a line by line comparison of Dan Abramove's Todo list demo for Redux and my porting of the Todo list to Alt implementation.

To run the [sample code from Github](https://github.com/eth