Skip to content Skip to sidebar Skip to footer

What Has Changed In Lodash From 3 To 4 That This Code Is Not Working?

I have a code like this: const _ = require('lodash'); const fn = _.partialRight(_.pick, _.identity); const x = { some: 'value', empty: null }; const y = fn(x); console.log('x:'

Solution 1:

change your const fn = _.partialRight(_.pick, _.identity) to const fn = _.partialRight(_.pickBy, _.identity);

_.pick used to be just one function but they broke it out into _.pick and _.pickBy in the latest updates. you would use _.pick when you are passing in known keys and _.pickBy when you are using a custom function to test if a key/value should be picked based on your own parameters,

https://lodash.com/docs/4.15.0#pick

https://lodash.com/docs/4.15.0#pickBy

Post a Comment for "What Has Changed In Lodash From 3 To 4 That This Code Is Not Working?"