We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
removeFalseProps()
1 parent 4bbd5d8 commit 2f2dd7bCopy full SHA for 2f2dd7b
src/utils/removeFalseProps.js
@@ -0,0 +1,12 @@
1
+export default function removeFalseyProps (props = {}) {
2
+ return Object.fromEntries(
3
+ Object.entries(props)
4
+ // Remove entries with `undefined`, `null` or `false` values.
5
+ .filter(([key, value]) => (value === 0 || Boolean(value)))
6
+ .map(([key, value]) => {
7
+ return (typeof value === 'object')
8
+ ? [key, removeFalseyProps(value)]
9
+ : [key, value]
10
+ })
11
+ )
12
+}
0 commit comments