Skip to content

Instantly share code, notes, and snippets.

@timsuchanek
Created October 25, 2016 13:54
Show Gist options
  • Save timsuchanek/0bbb77ed32b973f206a2fa0d32f1936c to your computer and use it in GitHub Desktop.
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.
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