Skip to content

Instantly share code, notes, and snippets.

View SimpleZn's full-sized avatar

Simple.Z.N SimpleZn

  • 上海
View GitHub Profile
@arqex
arqex / formComponent.js
Created January 18, 2016 18:37
10.nonFunctionalReact
var MyForm = React.createClass({
render: function(){
return (
<ValidationForm ref="form" onSubmit={ this.validates }>
<Input name="title" validation="required" />
<Input name="age" validation="required,number" />
<Input name="email" validation={ value => value.match(/\S+@\S+\.\S+/) } />
</ValidationForm>
);
},
@matthewoden
matthewoden / Fullpage.js
Created June 24, 2015 00:37
How to set up server side rendering with react proxy loader, and avoid a checksum mismatch.
/*
So the above file here is my Full page react file. I do a couple things here:
- In the head, I inject my important CSS inline.
- In the body, I link to my commons chunk (with react, react-router, and anything that's going to be on every single page).
- Beneath that is the app entry file.
- Beneath that is a dynamically generated chunkfile, based on the current route.
Each of these are cachebusted with a hash, pulled from the webpack stats file.
*/
@spoike
spoike / reflux.js
Created June 29, 2014 22:23
A simpler implementation of React.JS's Flux
var EventEmitter = require('events').EventEmitter,
_ = require('lodash');
/**
* Creates an action functor object
*/
exports.createAction = function() {
var action = new EventEmitter(),
eventLabel = "action",
@davemo
davemo / api.proxy.server.js
Created November 6, 2012 21:56
A simple express.js server with a proxy that intercepts all requests with /api/ and proxies them to localhost:3000
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});