Skip to content

Commit e2cd6fe

Browse files
committed
deps: Upgrade react-redux to v6.
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.
1 parent 5666370 commit e2cd6fe

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

flow-typed/npm/react-redux_v5.x.x.js renamed to flow-typed/npm/react-redux_v6.x.x.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// flow-typed signature: be1a6a9041ded9d5eb2308664fa10a77
2-
// flow-typed version: c6154227d1/react-redux_v5.x.x/flow_>=v0.89.x <=v0.103.x
1+
// flow-typed signature: a09118d2093dc5b4eee045cd2a7dbf5a
2+
// flow-typed version: c6154227d1/react-redux_v6.x.x/flow_>=v0.104.x
33

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

3939
declare export type Options<S, OP, SP, MP> = {|
4040
pure?: boolean,
41-
withRef?: boolean,
41+
forwardRef?: boolean,
4242
areStatesEqual?: (next: S, prev: S) => boolean,
4343
areOwnPropsEqual?: (next: OP, prev: OP) => boolean,
4444
areStatePropsEqual?: (next: SP, prev: SP) => boolean,
@@ -205,6 +205,7 @@ declare module "react-redux" {
205205
declare export class Provider<Store> extends React$Component<{
206206
store: Store,
207207
children?: React$Node,
208+
...
208209
}> {}
209210

210211
declare export function createProvider(
@@ -222,7 +223,8 @@ declare module "react-redux" {
222223
renderCountProp?: string,
223224
shouldHandleStateChanges?: boolean,
224225
storeKey?: string,
225-
withRef?: boolean,
226+
forwardRef?: boolean,
227+
...
226228
};
227229

228230
declare type SelectorFactoryOptions<Com> = {
@@ -231,10 +233,11 @@ declare module "react-redux" {
231233
renderCountProp: ?string,
232234
shouldHandleStateChanges: boolean,
233235
storeKey: string,
234-
withRef: boolean,
236+
forwardRef: boolean,
235237
displayName: string,
236238
wrappedComponentName: string,
237239
WrappedComponent: Com,
240+
...
238241
};
239242

240243
declare type MapStateToPropsEx<S: Object, SP: Object, RSP: Object> = (
@@ -261,7 +264,7 @@ declare module "react-redux" {
261264
OP: Object,
262265
CP: Object,
263266
EFO: Object,
264-
ST: { [_: $Keys<Com>]: any },
267+
ST: { [_: $Keys<Com>]: any, ... },
265268
>(
266269
selectorFactory: SelectorFactory<Com, D, S, OP, EFO, CP>,
267270
connectAdvancedOptions: ?(ConnectAdvancedOptions & EFO),
@@ -272,5 +275,6 @@ declare module "react-redux" {
272275
createProvider: typeof createProvider,
273276
connect: typeof connect,
274277
connectAdvanced: typeof connectAdvanced,
278+
...
275279
};
276280
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"react-navigation-redux-helpers": "^3.0.8",
8484
"react-navigation-stack": "^2.8.2",
8585
"react-navigation-tabs": "^2.9.0",
86-
"react-redux": "^5.0.7",
86+
"react-redux": "^6.0.1",
8787
"redux": "^4.0.0",
8888
"redux-action-buffer": "^1.2.0",
8989
"redux-batched-actions": "^0.3.0",

src/compose/ComposeBox.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class ComposeBox extends PureComponent<Props, State> {
252252
if (lastWordPrefix === '@') {
253253
// https://github.com/eslint/eslint/issues/11045
254254
// eslint-disable-next-line no-unused-expressions
255-
this.mentionWarnings.current?.getWrappedInstance().handleMentionSubscribedCheck(completion);
255+
this.mentionWarnings.current?.handleMentionSubscribedCheck(completion);
256256
}
257257
};
258258

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

449449
return (
450450
<View style={this.styles.wrapper}>
451+
{/* $FlowFixMe - `MentionWarnings` should use a type-checked `connect` */}
451452
<MentionWarnings narrow={narrow} stream={stream} ref={this.mentionWarnings} />
452453
<View style={[this.styles.autocompleteWrapper, { marginBottom: height }]}>
453454
<TopicAutocomplete

src/compose/MentionWarnings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,5 @@ export default connect(
173173
}),
174174
null,
175175
null,
176-
{ withRef: true },
176+
{ forwardRef: true },
177177
)(MentionWarnings);

yarn.lock

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@
988988
core-js-pure "^3.0.0"
989989
regenerator-runtime "^0.13.4"
990990

991-
"@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":
991+
"@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":
992992
version "7.11.2"
993993
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.11.2.tgz#f549c13c754cc40b87644b9fa9f09a6a95fe0736"
994994
integrity sha512-TeWkU52so0mPtDcaCTxNBI/IHiz0pZgr8VEFqXFtZWpYD08ZB6FaSwVAS8MKRQAP3bYKiVjwysOJgMFY28o6Tw==
@@ -5732,7 +5732,7 @@ hoist-non-react-statics@^2.3.1:
57325732
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47"
57335733
integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==
57345734

5735-
hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
5735+
hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
57365736
version "3.3.2"
57375737
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
57385738
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@@ -9623,12 +9623,12 @@ react-intl@^2.4.0:
96239623
intl-relativeformat "^2.1.0"
96249624
invariant "^2.1.1"
96259625

9626-
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:
9626+
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:
96279627
version "16.13.1"
96289628
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
96299629
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
96309630

9631-
react-lifecycles-compat@^3.0.0, react-lifecycles-compat@^3.0.4:
9631+
react-lifecycles-compat@^3.0.4:
96329632
version "3.0.4"
96339633
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
96349634
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
@@ -9885,18 +9885,17 @@ react-navigation@^4.4.0:
98859885
"@react-navigation/core" "^3.7.6"
98869886
"@react-navigation/native" "^3.8.0"
98879887

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

99019900
react-refresh@^0.4.0:
99029901
version "0.4.3"

0 commit comments

Comments
 (0)