Skip to content

Commit

Permalink
deps: Upgrade react-redux to v6.
Browse files Browse the repository at this point in the history
v7 is the latest, but might as well get there incrementally.

The v6 release seems most excited to talk about its new use of the
new Context API, which sounds like it might mean a lot of breaking
changes we have to address manually (I guess I'm thinking of zulip#4222).
But no; in fact, there's just one small announced breaking change
that applies to us:

- The `withRef` option to `connect` has been replaced with
  `forwardRef`. If `{forwardRef : true}` has been passed to
  `connect`, adding a ref to the connected wrapper component will
  actually return the instance of the wrapped component.

So, make that change, including the implied removal of
`getWrappedInstance`; that bit of UI works fine on Android and iOS
after that removal.

There's a FlowTyped libdef for this version, so, take that. An
additional Flow error arose, falsely telling consumers of our
`connect`-wrapped `MentionWarnings` component that they need to pass
props like `auth`; in fact, those are not expected to be passed
because they're provided by `connect`. Just as we've done at the
`connect` call site, add a temporary $FlowFixMe until we can get
`connect` properly type-checked.

It looks like we don't want to linger on v6 for very long; v7
addresses some performance complaints that arose in v6. So, we'll
move to v7 ASAP.
  • Loading branch information
chrisbobbe committed Sep 21, 2020
1 parent 61179aa commit 1cd590c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: be1a6a9041ded9d5eb2308664fa10a77
// flow-typed version: c6154227d1/react-redux_v5.x.x/flow_>=v0.89.x <=v0.103.x
// flow-typed signature: a09118d2093dc5b4eee045cd2a7dbf5a
// flow-typed version: c6154227d1/react-redux_v6.x.x/flow_>=v0.104.x

/**
The order of type arguments for connect() is as follows:
Expand Down Expand Up @@ -38,7 +38,7 @@ declare module "react-redux" {

declare export type Options<S, OP, SP, MP> = {|
pure?: boolean,
withRef?: boolean,
forwardRef?: boolean,
areStatesEqual?: (next: S, prev: S) => boolean,
areOwnPropsEqual?: (next: OP, prev: OP) => boolean,
areStatePropsEqual?: (next: SP, prev: SP) => boolean,
Expand Down Expand Up @@ -205,6 +205,7 @@ declare module "react-redux" {
declare export class Provider<Store> extends React$Component<{
store: Store,
children?: React$Node,
...
}> {}

declare export function createProvider(
Expand All @@ -222,7 +223,8 @@ declare module "react-redux" {
renderCountProp?: string,
shouldHandleStateChanges?: boolean,
storeKey?: string,
withRef?: boolean,
forwardRef?: boolean,
...
};

declare type SelectorFactoryOptions<Com> = {
Expand All @@ -231,10 +233,11 @@ declare module "react-redux" {
renderCountProp: ?string,
shouldHandleStateChanges: boolean,
storeKey: string,
withRef: boolean,
forwardRef: boolean,
displayName: string,
wrappedComponentName: string,
WrappedComponent: Com,
...
};

declare type MapStateToPropsEx<S: Object, SP: Object, RSP: Object> = (
Expand All @@ -261,7 +264,7 @@ declare module "react-redux" {
OP: Object,
CP: Object,
EFO: Object,
ST: { [_: $Keys<Com>]: any },
ST: { [_: $Keys<Com>]: any, ... },
>(
selectorFactory: SelectorFactory<Com, D, S, OP, EFO, CP>,
connectAdvancedOptions: ?(ConnectAdvancedOptions & EFO),
Expand All @@ -272,5 +275,6 @@ declare module "react-redux" {
createProvider: typeof createProvider,
connect: typeof connect,
connectAdvanced: typeof connectAdvanced,
...
};
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"react-navigation-redux-helpers": "^3.0.8",
"react-navigation-stack": "^2.8.2",
"react-navigation-tabs": "^2.9.0",
"react-redux": "^5.0.7",
"react-redux": "^6.0.1",
"redux": "^4.0.0",
"redux-action-buffer": "^1.2.0",
"redux-batched-actions": "^0.3.0",
Expand Down
3 changes: 2 additions & 1 deletion src/compose/ComposeBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class ComposeBox extends PureComponent<Props, State> {
if (lastWordPrefix === '@') {
// https://github.com/eslint/eslint/issues/11045
// eslint-disable-next-line no-unused-expressions
this.mentionWarnings.current?.getWrappedInstance().handleMentionSubscribedCheck(completion);
this.mentionWarnings.current?.handleMentionSubscribedCheck(completion);
}
};

Expand Down Expand Up @@ -448,6 +448,7 @@ class ComposeBox extends PureComponent<Props, State> {

return (
<View style={this.styles.wrapper}>
{/* $FlowFixMe - `MentionWarnings` should use a type-checked `connect` */}
<MentionWarnings narrow={narrow} stream={stream} ref={this.mentionWarnings} />
<View style={[this.styles.autocompleteWrapper, { marginBottom: height }]}>
<TopicAutocomplete
Expand Down
2 changes: 1 addition & 1 deletion src/compose/MentionWarnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,5 @@ export default connect(
}),
null,
null,
{ withRef: true },
{ forwardRef: true },
)(MentionWarnings);
27 changes: 13 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@
core-js-pure "^3.0.0"
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.3.1", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4":
version "7.11.2"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.11.2.tgz#f549c13c754cc40b87644b9fa9f09a6a95fe0736"
integrity sha512-TeWkU52so0mPtDcaCTxNBI/IHiz0pZgr8VEFqXFtZWpYD08ZB6FaSwVAS8MKRQAP3bYKiVjwysOJgMFY28o6Tw==
Expand Down Expand Up @@ -5851,7 +5851,7 @@ hoist-non-react-statics@^2.3.1:
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47"
integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==

hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
Expand Down Expand Up @@ -9810,12 +9810,12 @@ react-intl@^2.4.0:
intl-relativeformat "^2.1.0"
invariant "^2.1.1"

react-is@^16.12.0, react-is@^16.13.0, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6:
react-is@^16.12.0, react-is@^16.13.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.2, react-is@^16.8.4, react-is@^16.8.6:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-lifecycles-compat@^3.0.0, react-lifecycles-compat@^3.0.4:
react-lifecycles-compat@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
Expand Down Expand Up @@ -10072,18 +10072,17 @@ react-navigation@^4.4.0:
"@react-navigation/core" "^3.7.6"
"@react-navigation/native" "^3.8.0"

react-redux@^5.0.7:
version "5.1.1"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.1.1.tgz#88e368682c7fa80e34e055cd7ac56f5936b0f52f"
integrity sha512-LE7Ned+cv5qe7tMV5BPYkGQ5Lpg8gzgItK07c67yHvJ8t0iaD9kPFPAli/mYkiyJYrs2pJgExR2ZgsGqlrOApg==
react-redux@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-6.0.1.tgz#0d423e2c1cb10ada87293d47e7de7c329623ba4d"
integrity sha512-T52I52Kxhbqy/6TEfBv85rQSDz6+Y28V/pf52vDWs1YRXG19mcFOGfHnY2HsNFHyhP+ST34Aih98fvt6tqwVcQ==
dependencies:
"@babel/runtime" "^7.1.2"
hoist-non-react-statics "^3.1.0"
"@babel/runtime" "^7.3.1"
hoist-non-react-statics "^3.3.0"
invariant "^2.2.4"
loose-envify "^1.1.0"
prop-types "^15.6.1"
react-is "^16.6.0"
react-lifecycles-compat "^3.0.0"
loose-envify "^1.4.0"
prop-types "^15.7.2"
react-is "^16.8.2"

react-refresh@^0.4.0:
version "0.4.3"
Expand Down

0 comments on commit 1cd590c

Please sign in to comment.