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
| class MyForm extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| value: "Hello!" | |
| } | |
| //bindings here | |
| } | |
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
| // action types | |
| const ADD_ACCOUNT = "ADD_ACCOUNT"; | |
| // action | |
| const addAccountAction = { | |
| type: ADD_ACCOUNT, | |
| title: "Account title", | |
| createdBy: "admin" | |
| }; |
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
| // action types | |
| // import types from 'actionTypes.js' | |
| function accounts(state = [], action) { | |
| switch(action.type) { | |
| case types.ADD_ACCOUNT: | |
| return [ | |
| ...state, | |
| { | |
| id: getNewId(), //fake method that returns new ID |
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
| /* | |
| expected state: | |
| { | |
| accounts: { | |
| items: [] | |
| isFetching: boolean | |
| fetchingErrorMessage: string | |
| } | |
| } |
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 { createStore, applyMiddleware, compose } from 'redux'; | |
| // import rootReducer from '../rootReducer'; | |
| // import createLogger from "redux-logger"; | |
| // import thunkMiddleware from "redux-thunk"; | |
| const loggerMiddleware = createLogger(); | |
| const initialState = { | |
| someProperty: [] | |
| }; |
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
| export const fetchAllStart = () => { | |
| return { | |
| type: constants.FETCH_ALL | |
| }; | |
| }; | |
| export const fetchAllSuccess = (items) => { | |
| return { | |
| type: constants.FETCH_ALL_SUCCESS, | |
| items |
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
| class MyComponent extends Component { | |
| render() { | |
| return <input ref={(element) => this._input = element} />; | |
| } | |
| componentDidMount() { | |
| this._input.focus(); | |
| } | |
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
| class Button extends React.Component { | |
| render() { | |
| return <button style={{background: this.context.color}}> {this.props.children}</button>; | |
| } | |
| } | |
| Button.contextTypes = { | |
| color: React.PropTypes.string | |
| }; |
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 {connect} from "react-redux"; | |
| import * as actions from "./actions"; | |
| import LoginForm from "./components/LoginForm"; | |
| */ | |
| export class Login extends Component { | |
| render() { | |
| return ( |
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 restify = require("restify"); | |
| // create server instance | |
| const server = restify.createServer(); | |
| // use plugins to parse body and query string of incoming requests | |
| server.use(restify.plugins.queryParser()); | |
| server.use(restify.plugins.bodyParser()); | |
| // start listening |