Created
October 25, 2016 13:54
-
-
Save timsuchanek/0bbb77ed32b973f206a2fa0d32f1936c to your computer and use it in GitHub Desktop.
Sometimes you have unwanted props in a child, especially when {...props} is used. This Wrapper Component filters them.
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 ExcludeProps(Component: any, filter: string[] = []) { | |
return (props) => { | |
const keys = Object.keys(props).filter(key => !filter.includes(key)) | |
const picked = lodash.pick(props, keys) | |
return <Component {...picked} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment