Releases: helpscout/react-utils
React Utils - v1.0.3
Add renderSpy component
This update adds a new HOC utility called renderSpy, which reports on the
mount/unmount/render cycles of a React component - very handy for
debugging performance!
Inspired by React's performance tools and react-performance
.
Examples
import React from 'react'
import renderSpy from '@helpscout/react-utils/dist/renderSpy'
class Napoleon extends React.Component {
...
}
export const renderSpy()(Napoleon)
Potential logs:
Napoleon Mounted
Napoleon Rendered
Changes: ['votedForPedro']
Previous: { votedForPedro: false }
Next: { votedForPedro: true }
Napoleon Unmounted
Note!! I decided to roll my own performance spy tool instead of using ReactPerformance.measure
because I couldn't get that library to work with our projects :(. Not sure why!
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' },
// }
}
...
}
React Utils - v1.0.1
getValidProps: Improve filtering
This update improve the prop filtering for getValidProps
and isPropValid
.
It uses the REGEX based algorithm borrowed from styled-components
.
Previously, this function was using the is-prop-valid
util from Emotion
.
It worked, for the most part. However, it did not filter out custom props that
were named similarly to default React props, mainly things beginning with on
.
Props like onOpen
or onDidClose
would be let through.
React Utils - v1.0.0
Yay! v1.0.0!
We've been using React Utils for a bit, and it's working great!
Latest update includes...
Add shared dependencies
This update adds hoist-non-react-statics
and create-react-context
dependencies. These functions are used on several React-based projects,
and it makes sense that it comes from a single place - especially to
reduce dependency overhead and improve bundling.
These functions are exposed as hoistNonReactStatics
and createContext
.
Basic integration tests have been written for these functions as well
as basic README docs.
React Utils - v0.0.4
Add missing exports to main index.js
This update adds some missing function exports to the main
index.js of react-utils
.
Also, a test file was refactored for ESLint.
React Utils - v0.0.3
"Rest": Prop filtering
This update adds 2 new functions: getValidProps
(alias restProps
) and getCustomProps
.
They work to filter in/out default React-safe props.
Examples
import React from 'react'
import getValidProps from '@helpscout/react-utils/dist/getValidProps'
class UncleRico extends React.Component {
...
render () {
const rest = {getValidProps(this.props)}
return (<div {...rest} />}
}
}
React Utils - v0.0.2
Zero: Update
This update bumps Zero to v0.0.7, which improves the Babel transformed
dist code.