Created
December 14, 2021 04:09
-
-
Save alanbsmith/2c8cc2ff54578d827ef7a7705ed6e307 to your computer and use it in GitHub Desktop.
Simplified guard and callback example
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
const MyToggleButton = ({ isContentReady, {...props} }) => { | |
const modelConfig = { | |
isIntiallyToggled: true, | |
shouldToggle: (data, state) => { | |
if (!iContentReady) { | |
return false; | |
} | |
return true; | |
}, | |
onToggle: (data, prevState) => { | |
console.log('toggled!'); | |
} | |
} | |
const toggleButtonModel = useToggleButtonModel(modelConfig); | |
return <ToggleButton model={toggleButtonModel} {...props} /> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment