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
export default class Provider extends Component { | |
getChildContext() { | |
return { store: this.store } | |
} | |
constructor(props, context) { | |
super(props, context) | |
this.store = props.store | |
} |
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
class App extends React.Component{ | |
render = () => <div className="app">{this.props.children}</div> | |
} | |
class Greeting extends React.Component{ | |
render = () => <p style={this.context.style}>Hello world!</p> | |
} | |
Greeting.contextTypes = { | |
color: React.PropTypes.string, | |
backgroundColor: React.PropTypes.string | |
} |
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 { compose } from 'redux'; | |
const ToUpper = (Component) => ({ text }) => <Component text={text.toUpper()} \> | |
const WithUnderscores = (Component) => ({ text }) => <Component text={text.split(' ').join('_')} /> | |
export default compose(ToUpper, WithUnderscores); | |
// use like this |
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 { useState } from 'react'; | |
function useWhy(deps, id = null, logger = console.log) { | |
const [prevDeps, setPrevDeps] = useState(deps); | |
let changed = false; | |
deps.forEach((d, i) => { | |
if (d !== prevDeps[i]) { | |
changed = true; | |
logger(`Why ${id}: dep ${i} has changed from ${prevDeps[i]} to ${d}`); | |
} |
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
-- Add the following to your init.lua (or create it if it doesn't exist) | |
local Keyboard = require "keyboard" | |
Keyboard:init() |
OlderNewer