This repository was archived by the owner on Nov 9, 2024. It is now read-only.
This repository was archived by the owner on Nov 9, 2024. It is now read-only.
Tippy ignores plugins' "onShow" lifecycle hook returning false. #644
Closed
Description
Bug description
If a plugin's lifecycle hook for "onShow" returns false, it is ignored and the tip is shown anyway. This seems unexpected.
Suggestion
Fixing this would be rather tricky, as there can be some ambiguous cases (one plugin returning false, another not, etc). I suggest updating the "lifecycle" docs to denote that returning false from a plugin has no effect.
Workaround
My workaround is to override the onShow
prop in onCreate
. Please let me know if this seems reasonable and future-proof:
const myPluginThatSometimesCancelsShow = {
fn: function() {
return {
onCreate: function(instance) {
const origOnShow = instance.props.onShow;
instance.props.onShow = function(){
if ( /* some internal logic */ ) { return false; }
if (origOnShow) return origOnShow();
}
},
}
}
};
Activity
atomiks commentedon Nov 23, 2019
Yeah I agree. The ability to return false from those is not really composable so it's limited to the props hooks only.
atomiks commentedon Nov 24, 2019
I wouldn't recommend monkey-patching as you've done really due to conflicts as you mentioned. It's not composable - here's a good article as to why. You might run into weird bugs later on down the track due to it and forget that there's a plugin causing the problem 😭