diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 7a8674bd56c..97819071e12 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -227,7 +227,10 @@ rules: - devDependencies: ['**/__tests__/**/*.js', tools/**] no-restricted-imports: - error - - patterns: ['**/__tests__/**'] + - patterns: + - group: ['**/__tests__/**'] + - group: ['/react-redux'] + message: 'Use our own src/react-redux.js instead.' import/no-cycle: off # This would be nice to fix; but isn't easy. import/export: off # This is redundant with Flow, and buggy. diff --git a/src/boot/StoreProvider.js b/src/boot/StoreProvider.js index 1b5d4a3b73f..748a627b6f3 100644 --- a/src/boot/StoreProvider.js +++ b/src/boot/StoreProvider.js @@ -1,9 +1,9 @@ /* @flow strict-local */ import React, { PureComponent } from 'react'; import type { Node } from 'react'; -import { Provider } from 'react-redux'; import { observeStore } from '../redux'; +import { Provider } from '../react-redux'; import * as logging from '../utils/logging'; import { getAccount, tryGetActiveAccountState } from '../selectors'; import store, { restore } from './store'; diff --git a/src/react-redux.js b/src/react-redux.js index 135dce0d1ec..0b79cf47867 100644 --- a/src/react-redux.js +++ b/src/react-redux.js @@ -1,5 +1,8 @@ /* @flow strict-local */ import type { ComponentType, ElementConfig } from 'react'; +/* eslint-disable no-restricted-imports */ +// This file is where we type-wrap items from react-redux for use in the +// rest of the codebase. import { connect as connectInner, useSelector as useSelectorInner, @@ -9,6 +12,11 @@ import { import type { PerAccountState, GlobalState, Dispatch, GlobalDispatch } from './types'; import type { BoundedDiff } from './generics'; +// There's not a lot to say about the type of `Provider`, and it only has +// one use-site anyway; so we don't wrap it. But do re-export it from here, +// so everything else can uniformly never import directly from react-redux. +export { Provider } from 'react-redux'; + /* eslint-disable flowtype/generic-spacing */ // We leave this as invariant in `C` (i.e., we don't write `-C` or `+C`)