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 {promiseable, renderWhenLoaded} from "./promise" | |
| export default class View extends Component { | |
| constructor() { | |
| super() | |
| this.state = { | |
| data: {a: 1} | |
| } |
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
| // Place your settings in this file to overwrite default and user settings. | |
| { | |
| "files.exclude": { | |
| "**/.git": true, | |
| "**/.svn": true, | |
| "**/.hg": true, | |
| "**/.DS_Store": true, | |
| "src/**/*.jsx": true | |
| } | |
| } |
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 Inferno from 'inferno'; | |
| import Component from 'inferno-component'; | |
| import './App.css'; | |
| import Repeater from "./Repeater" | |
| import DisplayProps from "./DisplayProps" | |
| class App extends Component { | |
| constructor(props) { | |
| super(props) |
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
| require("colors") | |
| exports.createLogger = (type) => ({ | |
| log: (...args) => console.log(`[${type}]`.gray, ...args), | |
| warn: (...args) => console.log(`[${type}]`.cyan, ...args), | |
| error: (...args) => console.log(`[${type}]`.red, ...args), | |
| success: (...args) => console.log(`[${type}]`.green, ...args) | |
| }) |
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
| function compose(composeFn, param) { | |
| if(typeof composeFn != "function") | |
| return {} | |
| return composeFn(param) | |
| } | |
| function connectProps(store, mapStateToProps, mapDispatchToProps) { | |
| return { | |
| ...compose(mapStateToProps, store.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
| import TodoList from "./todo-list" | |
| function connect(mapStateToProps, mapDispatchToProps) { | |
| return (Target) => { | |
| class Connected extends Component { | |
| render() { | |
| // we pass the props down | |
| return (<Target {...this.props} />) | |
| } |
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
| function connect(mapStateToProps, mapDispatchToProps) { | |
| return (Target) => { | |
| // we need to return a class | |
| class Connected extends Component { | |
| render() { | |
| return <Target /> | |
| } | |
| } |
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
| function connect(mapStateToProps, mapDispatchToProps) { | |
| // Target is a component, TodoList in our example | |
| return Target => { | |
| // do something with it | |
| } | |
| } |
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
| // example from http://redux.js.org/docs/basics/UsageWithReact.html | |
| // annotated and simplified for this Medium story | |
| import { connect } from 'react-redux' | |
| import TodoList from "./todo-list" | |
| const mapStateToProps = (state) => { | |
| return { | |
| todos: state.todos // bound to `this.props.todos` | |
| } |
NewerOlder