This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "es6", | |
"version": "1.0.0", | |
"description": "My first ES6 project", | |
"main": "main.js", | |
"scripts": { | |
"build": "webpack --optimize-minimize && cp -r src/* cordova/www" | |
}, | |
"author": "Didier Franc", | |
"license": "MIT", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
brew install node | |
npm install -g cordova webpack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
entry: "./src/main.js", | |
output: { | |
path: __dirname + "/src", | |
filename: "bundle.js" | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.js$/, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm init | |
npm install babel-loader babel-core babel-preset-es2015 --save-dev | |
npm install autoroute.js --save | |
echo '{ "presets": ["es2015"] }' > .babelrc | |
cordova create cordova com.example.appname AppName | |
cd cordova | |
cordova platform add ios | |
cordova run ios --device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const get = u => fetch(u).then(r => r.json()) | |
const profile = async() => { | |
let data = await get(url) | |
let { pseudo, email, avatar } = data | |
} | |
// 👉 http://babeljs.io/docs/plugins/transform-runtime/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Spinner = () => ( | |
<p>Loading ...</p> | |
) | |
const List = ({items}) => ( | |
<ul> | |
{items.maps((item, i) => <li key={i}>{item.text}</li>)} | |
</ul> | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const path = require('path') | |
const express = require('express') | |
const compression = require('compression') | |
const bodyParser = require('body-parser') | |
const jwt = require('jsonwebtoken') | |
// Allow CORS | |
const origin = '*' | |
const app = express() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Login from './Login' | |
import Signup from './Signup' | |
import Header from './Header' | |
import Home from './Home' | |
const App = ({ user }) => ( | |
<Body> | |
<Header /> | |
{user.loggedIn ? <Route path="/" component={Home} /> : <Redirect to="/login" />} | |
<Route path="/signup" component={Signup} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Async from 'react-code-splitting' | |
import Login from './Login' | |
import Signup from './Signup' | |
import Header from './Header' | |
const Home = () => <Async load={import('./Home')} /> | |
const App = ({ user }) => ( | |
<Body> | |
<Header /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Login from './Login' | |
import Signup from './Signup' | |
import Header from './Header' | |
class Home extends React.Component { | |
componentWillMount = () => { | |
import('./Home').then(Component => { | |
this.Component = Component | |
this.forceUpdate() | |
}) |
OlderNewer