Created
January 10, 2018 23:10
-
-
Save monteslu/ce7c8bf5f2d81e60038ec9a1af7feea9 to your computer and use it in GitHub Desktop.
stupid hack
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 from 'react'; | |
import { connect } from 'react-redux'; | |
import { show, hide } from '../state/menu'; | |
class CoolComponent extends React.Component { | |
addActions ( actions ) { | |
actions.forEach((action) => { | |
this[action] = (a,b,c,d,e,f,g) => { | |
this.props[action].apply(this, [a,b,c,d,e,f,g]); | |
} | |
}) | |
} | |
} | |
class Menu extends CoolComponent { | |
constructor () { | |
super(); | |
this.addActions(['show', 'hide']); | |
} | |
render () { | |
const { menu } = this.props; | |
console.log('render menu', this.props); | |
return ( | |
<div> | |
<button onClick={this.show}>Trigger Modal</button> | |
<button onClick={this.hide}>Close Modal</button> | |
stuff | |
</div> | |
); | |
} | |
} | |
const ConnectedMenu = connect((state) => { | |
const { menu } = state; | |
return { menu }; | |
}, { show, hide })(Menu); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment