React Utils - v1.0.2
Add getShallowDiffs utility
This update adds getShallowDiffs, a utility to help spot the differences between
prev/next props. This is handy when trying to figure out why a React component
has updated, by tapping into lifecycle hooks, such as componentDidUpdate.
Example
import React from 'react'
import getShallowDiffs from '@helpscout/react-utils/dist/getShallowDiffs'
class Napolean extends React.Component {
...
componentDidUpdate (prevProps) {
console.log(getShallowDiffs(prevProps, this.props))
// {
// diffs: ['propName'],
// previous: { propName: 'a' },
// next: { propName: 'b' },
// }
}
...
}