nodemon session-cookie.js
> 127.0.0.1:8000
# visit /login
> Redirects to /admin with cookie
# visit /logout
> Redirects to / with cookie deleted
class MyPlugin { | |
constructor() { | |
this.commands = { | |
graphiql: { | |
usage: 'Creates graphiql server', | |
lifecycleEvents: ['start'], | |
}, | |
}; | |
this.hooks = { |
const { | |
graphql, | |
GraphQLSchema, | |
GraphQLObjectType, | |
GraphQLString | |
} = require('graphql'); | |
const schema = new GraphQLSchema({ | |
query: new GraphQLObjectType({ | |
name: 'RootQueryType', |
Minimal prototype of React, Redux, Redux Thunks +React Bootstrap + Bootstrap Material Design + fetch + jsonplaceholder.
#!/bin/sh | |
# Usage: | |
# sh download-node-nightly.sh | |
hasxz=$(which xzcat) | |
os=$(uname | tr '[A-Z]' '[a-z]') | |
arch=$(uname -m) | |
pwd=$(PWD) |
The 0.13.0
improvements to React Components are often framed as "es6 classes" but being able to use the new class syntax isn't really the big change. The main thing of note in 0.13
is that React Components are no longer special objects that need to be created using a specific method (createClass()
). One of the benefits of this change is that you can use the es6 class syntax, but also tons of other patterns work as well!
Below are a few examples creating React components that all work as expected using a bunch of JS object creation patterns (https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&%20object%20prototypes/ch4.md#mixins). All of the examples are of stateful components, and so need to delegate to React.Component
for setState()
, but if you have stateless components each patterns tends to get even simpler. The one major caveat with react components is that you need to assign props
and context
to the component instance otherwise the component will be static. The reason is
{ | |
"ecmaFeatures": { | |
"jsx": true, | |
"modules": true, | |
"arrowFunctions": true, | |
"blockBindings": true, | |
"defaultParams": true, | |
"objectLiteralShorthandProperties": true | |
}, | |
"rules": { |
var async = require('async'); | |
function waitSecond(cb) { | |
setTimeout(function(){ | |
cb(null, 'waited 1 second'); | |
}, 1000); | |
} | |
async.series([ | |
waitSecond, |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="initial-scale=1"> | |
<title>Document</title> | |
</head> | |
<body> | |