Skip to content

Instantly share code, notes, and snippets.

View enkot's full-sized avatar
👌
Focusing

Taras Batenkov enkot

👌
Focusing
View GitHub Profile
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 );
const Dispatcher = require('flux').Dispatcher;
const AppDispatcher = new Dispatcher();
/* ... */
addCard() {
AppDispatcher.dispatch({
actionType: 'ADD_ITEM',
city: 'Toronto'
});
render() {
const handleClick = () => {
this.addCard(this.refs.item.value)
};
return (
<div>
<input ref="item" />
<button onClick={handleClick}>Add item</button;
</div>
@enkot
enkot / App.js
Last active September 2, 2017 13:22
import React, { Component } from 'react';
import { render } from 'react-dom';
let id = 0;
class App extends Component {
state = { cards: [] }
addCard(text) {
this.setState({
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) {
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
"scripts": {
"start": "webpack-dev-server"
},
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
"presets": ["es2015", "react"]
}