Skip to content

Instantly share code, notes, and snippets.

@jquense
Last active December 17, 2015 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jquense/4bd786bba07b17d112b7 to your computer and use it in GitHub Desktop.
Save jquense/4bd786bba07b17d112b7 to your computer and use it in GitHub Desktop.
class Tab {
static childContextTypes = {
registerHook: PropTypes.func
}
constructor() {
super()
this._hooks = []
}
getChildContext() {
return {
registerHook: fn => this._hooks.push(fn)
}
}
onClose() {
if (this._hooks.some(fn => fn()))
return
// close logic
}
render() {
//...
}
}
class SomeChild {
static contextTypes = {
registerHook: PropTypes.func
}
constructor() {
super()
this._hooks = []
}
componentWillMount(){
this.context.registerHook(() => {
return this.isDirty
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment