This patch release fixes some minor TS types issues, and updates the rarely-used areStatesEqual
option for connect
to now pass through ownProps
for additional use in determining which pieces of state to compare if desired.
Note: 8.0.3 was accidentally published without one of these fixes. Use 8.0.4 instead.
Changelog
TS Fixes
We've fixed an import of React
that caused issues with the allowSyntheticDefaultImports
TS compiler flag in user projects.
connect
already accepted a custom context instance as props.context
, and had runtime checks in case users were passing through a real value with app data as props.context
instead. However, the TS types did not handle that case, and this would fail to compile. If your own component expects props.context
with actual data, connect
's types now use that type instead.
The ConnectedProps<T>
type had a mismatch with React's built-in React.ComponentProps<Component>
type, and that should now work correctly.
Other Changes
The areStatesEqual
option to connect
now receives ownProps
as well, in case you need to make a more specific comparison with certain sections of state.
The new signature is:
{
areStatesEqual?: (
nextState: State,
prevState: State,
nextOwnProps: TOwnProps,
prevOwnProps: TOwnProps
) => boolean
}
What's Changed
- Don't require allowSyntheticDefaultImports: true by @apepper in #1924
- Fixed type issue with
ComponentProps
from older@types/react
by @Andarist in #1956 - connect: pass ownProps to areStatesEqual by @jspurlin in #1951
- Omit built-in context prop if user component props include context by @markerikson in #1958
Full Changelog: v8.0.2...v8.0.4