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 { connectUi } from './ui' | |
import reducer, { increment } from './reducer' | |
export default const compose( | |
connectUi( | |
{ reducer, initialState: { value: 0 } }, | |
({ value }) => ({ value }), | |
(dispatch, { uiKey }) => ({ | |
onIncrement: item => dispatch(increment(uiKey)) | |
}) |
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
const myStyled = (TargetComponent) => ([style]) => class extends React.Component { | |
componentDidMount() { | |
this.element.setAttribute('style', style); | |
} | |
render() { | |
return ( | |
<TargetComponent {...this.props} ref={element => this.element = element } /> | |
); | |
} |
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
const myStyled = (TargetComponent) => (strs, ...exprs) => class extends React.Component { | |
interpolateStyle() { | |
const style = exprs.reduce((result, expr, index) => { | |
const isFunc = typeof expr === 'function'; | |
const value = isFunc ? expr(this.props) : expr; | |
return result + value + strs[index + 1]; | |
}, strs[0]); | |
this.element.setAttribute('style', style); |
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
StyledComponent.componentId = componentId; | |
StyledComponent.target = TargetComponent; |
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
function observable(target: any, propertyKey: string) { | |
console.log(`decorate ${propertyKey}`); | |
} | |
class State { | |
@observable foo; | |
} |
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
function observable(target, propertyKey) { | |
console.log(`decorate ${propertyKey}`); | |
} | |
class State { | |
} | |
observable(State.prototype, "foo"); |
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
function observable(target: any, propertyKey: string): PropertyDecorator { | |
console.log(`decorate ${propertyKey}`); | |
// This is property descriptor | |
return { | |
get() {}, | |
set() {}, | |
}; | |
} |
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
function observable(target, propertyKey) { | |
console.log(`decorate ${propertyKey}`); | |
return { | |
get() {}, | |
set() {}, | |
}; | |
} | |
class State { |
OlderNewer