From 44e752d52bcebde43842b046b47eedf07b7cfecf Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:34:45 +0100 Subject: [PATCH] fix(deps): update dependency react-redux to v9 (#5025) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [react-redux](https://togithub.com/reduxjs/react-redux) | [`^7.2.9` -> `^9.1.0`](https://renovatebot.com/diffs/npm/react-redux/7.2.9/9.1.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/react-redux/9.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-redux/9.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-redux/7.2.9/9.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-redux/7.2.9/9.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
reduxjs/react-redux (react-redux) ### [`v9.1.0`](https://togithub.com/reduxjs/react-redux/compare/v9.0.4...v9.1.0) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v9.0.4...v9.1.0) ### [`v9.0.4`](https://togithub.com/reduxjs/react-redux/releases/tag/v9.0.4) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v9.0.3...v9.0.4) This **bugfix release** updates the React Native peer dependency to be `>= 0.69`, to better reflect the need for React 18 compat and (hopefully) resolve issues with the `npm` package manager throwing peer dep errors on install. #### What's Changed - Allow react-native newer than 0.69 as peer dependency by [@​R3DST0RM](https://togithub.com/R3DST0RM) in [https://github.com/reduxjs/react-redux/pull/2107](https://togithub.com/reduxjs/react-redux/pull/2107) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v9.0.3...v9.0.4 ### [`v9.0.3`](https://togithub.com/reduxjs/react-redux/releases/tag/v9.0.3) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v9.0.2...v9.0.3) This **bugfix release** drops the ReactDOM / React Native specific use of render batching, as React 18 now automatically batches, and updates the React types dependencies #### Changelog ##### Batching Dependency Updates React-Redux has long depended on React's `unstable_batchedUpdates` API to help batch renders queued by Redux updates. It also re-exported that method as a util named `batch`. However, React 18 now auto-batches all queued renders in the same event loop tick, so `unstable_batchedUpdates` is effectively a no-op. Using `unstable_batchedUpdates` has always been a pain point, because it's exported by the renderer package (ReactDOM or React Native), rather than the core `react` package. Our prior implementation relied on having separate `batch.ts` and `batch.native.ts` files in the codebase, and expecting React Native's bundler to find the right transpiled file at app build time. Now that we're pre-bundling artifacts in React-Redux v9, that approach has become a problem. Given that React 18 already batches by default, there's no further need to continue using `unstable_batchedUpdates` internally, so we've removed our use of that and simplified the internals. We still export a `batch` method, but it's effectively a no-op that just immediately runs the given callback, and we've marked it as `@deprecated`. We've also updated the build artifacts and packaging, as there's no longer a need for an `alternate-renderers` entry point that omits batching, or a separate artifact that imports from `"react-native"`. #### What's Changed - Drop renderer-specific batching behavior and deprecate `batch` by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2104](https://togithub.com/reduxjs/react-redux/pull/2104) - Drop `@types/react-dom` and lower `@types/react` to min needed by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2105](https://togithub.com/reduxjs/react-redux/pull/2105) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v9.0.2...v9.0.3 ### [`v9.0.2`](https://togithub.com/reduxjs/react-redux/releases/tag/v9.0.2) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v9.0.1...v9.0.2) This **bugfix release** makes additional tweaks to the React Native artifact filename to help resolve import and bundling issues with RN projects. #### What's Changed - Change react-native output extension from `.mjs` to `.js` by [@​aryaemami59](https://togithub.com/aryaemami59) in [https://github.com/reduxjs/react-redux/pull/2102](https://togithub.com/reduxjs/react-redux/pull/2102) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v9.0.1...v9.0.2 ### [`v9.0.1`](https://togithub.com/reduxjs/react-redux/releases/tag/v9.0.1) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v9.0.0...v9.0.1) This **bugfix release** updates the package to include a new `react-redux.react-native.js` bundle that specifically imports React Native, and consolidates all of the `'react'` imports into one file to save on bundle size (and enable some tricky React Native import handling). ##### What's Changed - Add an RN-specific bundle and consolidate imports by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2100](https://togithub.com/reduxjs/react-redux/pull/2100) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v9.0.0...v9.0.1 ### [`v9.0.0`](https://togithub.com/reduxjs/react-redux/releases/tag/v9.0.0) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.1.3...v9.0.0) This **major release**: - Switches to requiring React 18 and Redux Toolkit 2.0 / Redux 5.0 - Updates the packaging for better ESM/CJS compatibility and modernizes the build output - Updates the options for dev mode checks in `useSelector` - Adds a new React Server Components artifact that throws on use, to better indicate compat issues This release has **breaking changes**. This release is part of a wave of major versions of all the Redux packages: **Redux Toolkit 2.0, Redux core 5.0, React-Redux 9.0, Reselect 5.0, and Redux Thunk 3.0**. For full details on all of the breaking changes and other significant changes to all of those packages, see the **["Migrating to RTK 2.0 and Redux 5.0" migration guide](https://redux.js.org/usage/migrations/migrating-rtk-2)** in the Redux docs. > \[!NOTE] > The Redux core, Reselect, and Redux Thunk packages are included as part of Redux Toolkit, and RTK users do not need to manually upgrade them - you'll get them as part of the upgrade to RTK 2.0. (If you're not using Redux Toolkit yet, [**please start migrating your existing legacy Redux code to use Redux Toolkit today!**](https://redux.js.org/usage/migrating-to-modern-redux)) > React-Redux is a separate, package, but we expect you'll be upgrading them together. ```bash ##### React-Redux npm install react-redux yarn add react-redux ##### RTK npm install @​reduxjs/toolkit yarn add @​reduxjs/toolkit ##### Standalone Redux core npm install redux yarn add redux ``` ##### Changelog ##### React 18 and RTK 2 / Redux core 5 Are Required React-Redux 7.x and 8.x worked with all versions of React that had hooks (16.8+, 17.x, 18.x). However, React-Redux v8 used React 18's new `useSyncExternalStore` hook. In order to maintain backwards compatibility with older React versions, we used the `use-sync-external-store` "shim" package that provided an official userland implementation of the `useSyncExternalStore` hook when used with React 16 or 17. This meant that if you *were* using React 18, there were a few hundred extra bytes of shim code being imported even though it wasn't needed. For React-Redux v9, we're switching so that **React 18 is now *required*!** This both simplifies the maintenance burden on our side (fewer versions of React to test against), and also lets us drop the extra bytes because we can import `useSyncExternalStore` directly. React 18 has been out for a year and a half, and other libraries like React Query are also switching to require React 18 in their next major version. This seems like a reasonable time to make that switch. Similarly, React-Redux now depends on Redux core v5 for updated TS types (but not runtime behavior). We strongly encourage all Redux users to be using Redux Toolkit, which already includes the Redux core. Redux Toolkit 2.0 comes with Redux core 5.0 built in. ##### ESM/CJS Package Compatibility The biggest theme of the Redux v5 and RTK 2.0 releases is trying to get "true" ESM package publishing compatibility in place, while still supporting CJS in the published package. **The primary build artifact is now an ESM file, `dist/react-redux.mjs`**. Most build tools should pick this up. There's also a CJS artifact, and a second copy of the ESM file named `react-redux.legacy-esm.js` to support Webpack 4 (which does not recognize the `exports` field in `package.json`). There's also two special-case artifacts: an "alternate renderers" artifact that should be used for any renderer other than ReactDOM or React Native (such as the `ink` React CLI renderer), and a React Server Components artifact that throws when any import is used (since using hooks or context would error anyway in an RSC environment). Additionally, all of the build artifacts now live under `./dist/` in the published package. Previous releases actually shipped separate individual transpiled source files - the build artifacts are now pre-bundled, same as the rest of the Redux libraries. ##### Modernized Build Output We now publish modern JS syntax targeting ES2020, including optional chaining, object spread, and other modern syntax. If you need to ##### Build Tooling We're now building the package using https://github.com/egoist/tsup. We also now include sourcemaps for the ESM and CJS artifacts. ##### Dropping UMD Builds Redux has always shipped with UMD build artifacts. These are primarily meant for direct import as script tags, such as in a CodePen or a no-bundler build environment. We've dropped those build artifacts from the published package, on the grounds that the use cases seem pretty rare today. There's now a `react-redux.browser.mjs` file in the package that can be loaded from a CDN like Unpkg. If you have strong use cases for us continuing to include UMD build artifacts, please let us know! ##### React Server Components Behavior Per [Mark's post "My Experience Modernizing Packages to ESM"](https://blog.isquaredsoftware.com/2023/08/esm-modernization-lessons/), one of the recent pain points has been [the rollout of React Server Components and the limits the Next.js + React teams have added to RSCs](https://blog.isquaredsoftware.com/2023/08/esm-modernization-lessons/#problems-with-next-js-and-react-server-components). We see many users try to import and use React-Redux APIs in React Server Component files, then get confused why things aren't working right. To address that, we've added a new entry point with a `"react-server"` condition. Every export in that file will throw an error as soon as it's called, to help catch this mistake earlier. ##### Dev Mode Checks Updated In [v8.1.0](https://togithub.com/reduxjs/react-redux/releases/tag/v8.1.0), we updated `useSelector` to accept an options object containing options to check for selectors that always calculate new values, or that always return the root state. We've renamed the `noopCheck` option to `identityFunctionCheck` for clarity. We've also changed the structure of the options object to be: ```ts export type DevModeCheckFrequency = 'never' | 'once' | 'always' export interface UseSelectorOptions { equalityFn?: EqualityFn devModeChecks?: { stabilityCheck?: DevModeCheckFrequency identityFunctionCheck?: DevModeCheckFrequency } } ``` ##### `hoist-non-react-statics` and `react-is` Deps Inlined Higher Order Components have been discouraged in the React ecosystem over the last few years. However, we still include the `connect` API. It's now in maintenance mode and not in active development. As described in [the React legacy docs on HOCs](https://legacy.reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over), one quirk of HOCs is needing to copy over static methods to the wrapper component. The `hoist-non-react-statics` package has been the standard tool to do that. We've inlined a copy of `hoist-non-react-statics` and removed the package dep, and confirmed that this improves tree-shaking. We've also done the same with the `react-is` package as well, which was also only used by `connect`. This should have no user-facing effects. ##### TypeScript Support We've dropped support for TS 4.6 and earlier, and our support matrix is now TS 4.7+. ##### What's Changed - Update packaging, build config, and entry points for v9 by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2038](https://togithub.com/reduxjs/react-redux/pull/2038) - Add stack to dev mode checks by [@​EskiMojo14](https://togithub.com/EskiMojo14) in [https://github.com/reduxjs/react-redux/pull/2064](https://togithub.com/reduxjs/react-redux/pull/2064) - add an extra entrypoint for React Server Components by [@​phryneas](https://togithub.com/phryneas) in [https://github.com/reduxjs/react-redux/pull/2062](https://togithub.com/reduxjs/react-redux/pull/2062) - Inline hoist-non-react-statics to eliminate a dep and help shaking by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2066](https://togithub.com/reduxjs/react-redux/pull/2066) - Make context typing more accurate by [@​EskiMojo14](https://togithub.com/EskiMojo14) in [https://github.com/reduxjs/react-redux/pull/2041](https://togithub.com/reduxjs/react-redux/pull/2041) - Fix `uSES` imports and run against RTK CI examples by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2070](https://togithub.com/reduxjs/react-redux/pull/2070) - Copy CI setup for RTK examples by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2072](https://togithub.com/reduxjs/react-redux/pull/2072) - Fix useSelector() in combination with lazy loaded components breaks with react v18 ([#​1977](https://togithub.com/reduxjs/react-redux/issues/1977)) by [@​jeroenpx](https://togithub.com/jeroenpx) in [https://github.com/reduxjs/react-redux/pull/2068](https://togithub.com/reduxjs/react-redux/pull/2068) - Actually add `sideEffects: "false"` to `package.json` in v9 by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2079](https://togithub.com/reduxjs/react-redux/pull/2079) - Inline `react-is` utils to fix tree-shaking in 9.0 by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2085](https://togithub.com/reduxjs/react-redux/pull/2085) - Rename `noopCheck` to `identityFunctionCheck` by [@​aryaemami59](https://togithub.com/aryaemami59) in [https://github.com/reduxjs/react-redux/pull/2091](https://togithub.com/reduxjs/react-redux/pull/2091) - Use scoped JSX for React types by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2092](https://togithub.com/reduxjs/react-redux/pull/2092) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.1.2...v9.0.0 ### [`v8.1.3`](https://togithub.com/reduxjs/react-redux/compare/v8.1.2...v8.1.3) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.1.2...v8.1.3) ### [`v8.1.2`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.1.2) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.1.1...v8.1.2) This version changes imports from the React package to namespace imports so the package can safely be imported in React Server Components as long as you don't actually use it - this is for example important if you want to use the React-specifc `createApi` function from Redux Toolkit. Some other changes: - The behaviour of the "React Context Singletons" from 8.1.1 has been adjusted to also work if you have multiple React instances of the same version (those will now be separated) and if you are in an environment without `globalThis` (in this case it will fall back to the previous behaviour). - We do no longer use Proxies, which should help with some very outdated consumers, e.g. smart TVs, that cannot even polyfill Proxies. **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.1.1...v8.1.2 ### [`v8.1.1`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.1.1) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.1.0...v8.1.1) This bugfix release tweaks the recent lazy context setup logic to ensure a single React context instance per React version, and removes the recently added RTK peerdep to fix an issue with Yarn workspaces. #### Changelog ##### React Context Singletons React Context has always relied on reference identity. If you have two different copies of React or a library in a page, that can cause multiple versions of a context instance to be created, leading to problems like the infamous "Could not find react-redux context" error. In [v8.1.0](https://togithub.com/reduxjs/react-redux/releases/tag/v8.1.0), we reworked the internals to lazily create our single `ReactReduxContext` instance to avoid issues in a React Server Components environment. This release further tweaks that to stash a single context instance per React version found in the page, thus hopefully avoiding the "multiple copies of the same context" error in the future. #### What's Changed - fix: fix typescript error on non exported type by [@​luzzif](https://togithub.com/luzzif) in [https://github.com/reduxjs/react-redux/pull/2034](https://togithub.com/reduxjs/react-redux/pull/2034) - create singleton context by React version by [@​phryneas](https://togithub.com/phryneas) in [https://github.com/reduxjs/react-redux/pull/2039](https://togithub.com/reduxjs/react-redux/pull/2039) - remove RTK peerDep by [@​markerikson](https://togithub.com/markerikson) in [`44fc725`](https://togithub.com/reduxjs/react-redux/commit/44fc725) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.1.0...v8.1.1 ### [`v8.1.0`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.1.0) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.0.7...v8.1.0) This **feature release** adds new development-mode safety checks for common errors (like poorly-written selectors), adds a workaround to fix crash errors when React-Redux hooks are imported into React Server Component files, and updates our hooks API docs page with improved explanations and updated links. #### Changelog ##### Development Mode Checks for `useSelector` We've had a number of users tell us over time that it's common to accidentally write selectors that have bad behavior and cause performance issues. The most common causes of this are either selectors that unconditionally return a new reference (such as `state => state.todos.map()` without any memoization ), or selectors that actually return the *entire* root state ( `state => state` ). We've updated `useSelector` to add safety checks in development mode that warn if these incorrect behaviors are detected: - Selectors will be called twice with the same inputs, and `useSelector` will warn if the results are different references - `useSelector` will warn if the selector result is actually the entire root `state` By default, **these checks only run *once* the first time `useSelector` is called**. This should provide a good balance between detecting possible issues, and keeping development mode execution performant without adding many unnecessary extra selector calls. If you want, you can configure this behavior globally by passing the enum flags directly to ``, or on a per-`useSelector` basis by passing an options object as the second argument: ```ts // Example: globally configure the root state "noop" check to run every time {children} ``` ```ts // Example: configure `useSelector` to specifically run the reference checks differently: function Component() { // Disable check entirely for this selector const count = useSelector(selectCount, { stabilityCheck: 'never' }) // run once (default) const user = useSelector(selectUser, { stabilityCheck: 'once' }) // ... } ``` This goes along with the similar safety checks we've added to [Reselect v5 alpha](https://togithub.com/reduxjs/reselect/releases/tag/v5.0.0-alpha.2) as well. ##### Context Changes We're still trying to work out how to properly use Redux and React Server Components together. One possibility is using RTK Query's `createApi` to define data fetching endpoints, and using the generated thunks to fetch data in RSCs, but it's still an open question. However, users have reported that merely importing *any* React-Redux API in an RSC file causes a crash, because `React.createContext` is not defined in RSC files. RTKQ's React-specific `createApi` entry point imports React-Redux, so it's been unusable in RSCs. This release adds a workaround to fix that issue, by using a proxy wrapper around our singleton `ReactReduxContext` instance and lazily creating that instance on demand. In testing, this appears to both continue to work in all unit tests, *and* fixes the import error in an RSC environment. We'd appreciate further feedback in case this change does cause any issues for anyone! We've also tweaked the internals of the hooks to do checks for correct `` usage when using a custom context, same as the default context checks. ##### Docs Updates We've cleaned up some of the Hooks API reference page, and updated links to the React docs. #### What's Changed - check for Provider even when using custom context by [@​EskiMojo14](https://togithub.com/EskiMojo14) in [https://github.com/reduxjs/react-redux/pull/1990](https://togithub.com/reduxjs/react-redux/pull/1990) - Add a stability check, to see if selector returns stable result when called with same parameters. by [@​EskiMojo14](https://togithub.com/EskiMojo14) in [https://github.com/reduxjs/react-redux/pull/2000](https://togithub.com/reduxjs/react-redux/pull/2000) - Add an E2E-ish test that verifies behavior when imported into RSCs by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2030](https://togithub.com/reduxjs/react-redux/pull/2030) - lazily create Context for RSC compat by [@​phryneas](https://togithub.com/phryneas) in [https://github.com/reduxjs/react-redux/pull/2025](https://togithub.com/reduxjs/react-redux/pull/2025) - Add warning for selectors that return the entire state by [@​EskiMojo14](https://togithub.com/EskiMojo14) in [https://github.com/reduxjs/react-redux/pull/2022](https://togithub.com/reduxjs/react-redux/pull/2022) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.0.7...v8.1.0 ### [`v8.0.7`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.7) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.0.6...v8.0.7) This release updates the peer dependencies to accept Redux Toolkit, and accept the ongoing RTK and Redux core betas as valid peer deps. > **Note**: These changes were initially in 8.0.6, but that had a typo in the peer deps that broke installation. Sorry! #### What's Changed - Bump Redux peer deps to accept 5.0 betas, and bump RTK dev dep by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2017](https://togithub.com/reduxjs/react-redux/pull/2017) - [`d45204f`](https://togithub.com/reduxjs/react-redux/commit/d45204f) : Fix broken RTK peer dep **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.0.5...v8.0.7 ### [`v8.0.6`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.6) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.0.5...v8.0.6) \~~This release updates the peer dependencies to accept Redux Toolkit, and accept the ongoing RTK and Redux core betas as valid peer deps.~~ **This release has a peer deps typo that breaks installation - please use 8.0.7 instead !** #### What's Changed - Bump Redux peer deps to accept 5.0 betas, and bump RTK dev dep by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/2017](https://togithub.com/reduxjs/react-redux/pull/2017) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.0.5...v8.0.6 ### [`v8.0.5`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.5) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.0.4...v8.0.5) This release fixes a few minor TS issues. #### What's Changed - `Provider`: pass state (`S`) generic through to `ProviderProps` by [@​OliverJAsh](https://togithub.com/OliverJAsh) in [https://github.com/reduxjs/react-redux/pull/1960](https://togithub.com/reduxjs/react-redux/pull/1960) - wrap `equalityFn` type in `NoInfer` by [@​phryneas](https://togithub.com/phryneas) in [https://github.com/reduxjs/react-redux/pull/1965](https://togithub.com/reduxjs/react-redux/pull/1965) - Fix wrapped component prop types when passing nullish mapDispatchToProps by [@​marconi1992](https://togithub.com/marconi1992) in [https://github.com/reduxjs/react-redux/pull/1928](https://togithub.com/reduxjs/react-redux/pull/1928) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.0.4...v8.0.5 ### [`v8.0.4`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.4) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.0.3...v8.0.4) 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` type had a mismatch with React's built-in `React.ComponentProps` 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: ```ts { areStatesEqual?: ( nextState: State, prevState: State, nextOwnProps: TOwnProps, prevOwnProps: TOwnProps ) => boolean } ``` #### What's Changed - Don't require allowSyntheticDefaultImports: true by [@​apepper](https://togithub.com/apepper) in [https://github.com/reduxjs/react-redux/pull/1924](https://togithub.com/reduxjs/react-redux/pull/1924) - Fixed type issue with `ComponentProps` from older `@types/react` by [@​Andarist](https://togithub.com/Andarist) in [https://github.com/reduxjs/react-redux/pull/1956](https://togithub.com/reduxjs/react-redux/pull/1956) - connect: pass ownProps to areStatesEqual by [@​jspurlin](https://togithub.com/jspurlin) in [https://github.com/reduxjs/react-redux/pull/1951](https://togithub.com/reduxjs/react-redux/pull/1951) - Omit built-in context prop if user component props include context by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1958](https://togithub.com/reduxjs/react-redux/pull/1958) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.0.2...v8.0.4 ### [`v8.0.3`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.3) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.0.2...v8.0.3) **This release was accidentally published without an intended fix - please use [v8.0.4](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.4) instead** ### [`v8.0.2`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.2) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.0.1...v8.0.2) This patch release tweaks the behavior of `connect` to print a one-time warning when the obsolete `pure` option is passed in, rather than throwing an error. This fixes crashes caused by libraries such as `react-beautiful-dnd` continuing to pass in that option (unnecessarily) to React-Redux v8. #### What's Changed - Show warning instead of throwing error that pure option has been removed by [@​ApacheEx](https://togithub.com/ApacheEx) in [https://github.com/reduxjs/react-redux/pull/1922](https://togithub.com/reduxjs/react-redux/pull/1922) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.0.1...v8.0.2 ### [`v8.0.1`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.1) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v8.0.0...v8.0.1) This release fixes an incorrect internal import of our `Subscription` type, which was causing TS compilation errors in some user projects. We've also listed `@types/react-dom` as an optional peerDep. There are no runtime changes in this release. #### What's Changed - Add optional peer dependency on [@​types/react-dom](https://togithub.com/types/react-dom) by [@​Methuselah96](https://togithub.com/Methuselah96) in [https://github.com/reduxjs/react-redux/pull/1904](https://togithub.com/reduxjs/react-redux/pull/1904) - fix(ts): incorrect import of `Subscription` causes `noImplicitAny` error by [@​vicrep](https://togithub.com/vicrep) in [https://github.com/reduxjs/react-redux/pull/1910](https://togithub.com/reduxjs/react-redux/pull/1910) **Full Changelog**: https://github.com/reduxjs/react-redux/compare/v8.0.0...v8.0.1 ### [`v8.0.0`](https://togithub.com/reduxjs/react-redux/releases/tag/v8.0.0) [Compare Source](https://togithub.com/reduxjs/react-redux/compare/v7.2.9...v8.0.0) This **major version** release updates `useSelector`, `connect`, and `` for compatibility with React 18, rewrites the React-Redux codebase to TypeScript (obsoleting use of `@types/react-redux`), modernizes build output, and removes the deprecated `connectAdvanced` API and the `pure` option for `connect`. npm i react-redux@latest yarn add react-redux@latest #### Overview, Compatibility, and Migration Our public API is still the same ( ``, `connect` and `useSelector/useDispatch`), but we've updated the internals to use the new `useSyncExternalStore` hook from React. React-Redux v8 is still compatible with all versions of React that have hooks (16.8+, 17.x, and 18.x; React Native 0.59+), and *should* just work out of the box. In most cases, it's very likely that the only change you will need to make is bumping the package version to `"react-redux": "^8.0"`. *If* you are using the rarely-used `connectAdvanced` API, you will need to rewrite your code to avoid that, likely by using the hooks API instead. Similarly, the `pure` option for `connect` has been removed. If you are using Typescript, React-Redux is now written in TS and includes its own types. You should remove any dependencies on `@types/react-redux`. While not directly tied to React-Redux, note that **the recently updated `@types/react@18` major version has changed component definitions to remove having `children` as a prop by default**. This causes errors if you have multiple copies of `@types/react` in your project. To fix this, tell your package manager to resolve `@types/react` to a single version. Details: [**React issue #​24304: React 18 types broken since release**](https://togithub.com/facebook/react/issues/24304#issuecomment-1094565891) Additionally, please see the React post on [**How to Ugprade to React 18**](https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html) for details on how to migrate existing apps to correctly use React 18 and take advantage of its new features. #### Changelog ##### React 18 Compatibility React-Redux now requires the new [`useSyncExternalStore` API in React 18](https://togithub.com/reactwg/react-18/discussions/86). By default, it uses the "shim" package which backfills that API in earlier React versions, so **React-Redux v8 is compatible with all React versions that have hooks** (16.8+, and React Native 0.59+) as its acceptable peer dependencies. We'd especially like to thank the React team for their extensive support and cooperation during the `useSyncExternalStore` development effort. They specifically designed `useSyncExternalStore` to support the needs and use cases of React-Redux, and we used React-Redux v8 as a testbed for how `useSyncExternalStore` would behave and what it needed to cover. This in turn helped ensure that `useSyncExternalStore` would be useful and work correctly for other libraries in the ecosystem as well. Our performance benchmarks show parity with React-Redux v7.2.5 for both `connect` and `useSelector`, so we do not anticipate any meaningful performance regressions. ##### `useSyncExternalStore` and Bundling The `useSyncExternalStore` shim is imported directly in the main entry point, so it's *always* included in bundles even if you're using React 18. This adds roughly 600 bytes minified to your bundle size. If you are using React 18 and would like to avoid that extra bundle cost, React-Redux now has a new `/next` entry point. This exports the exact same APIs, but directly imports `useSyncExternalStore` from React itself, and thus avoids including the shim. You can alias `"react-redux": "react-redux/next"` in your bundler to use that instead. ##### SSR and Hydration React 18 introduces a new `hydrateRoot` method for hydrating the UI on the client in Server-Side Rendering usage. As part of that, the `useSyncExternalStore` API requires that we pass in an alternate state value other than what's in the actual Redux store, and that alternate value will be used for the entire initial hydration render to ensure the initial rehydrated UI is an exact match for what was rendered on the server. After the hydration render is complete, React will then apply any additional changes from the store state in a follow-up render. React-Redux v8 supports this by adding a new `serverState` prop for ``. If you're using SSR, you should pass your serialized state to `` to ensure there are no hydration mismatch errors: ```ts import { hydrateRoot } from 'react-dom/client' import { configureStore } from '@​reduxjs/toolkit' import { Provider } from 'react-redux' const preloadedState = window.__PRELOADED_STATE__ const clientStore = configureStore({ reducer: rootReducer, preloadedState, }) hydrateRoot( document.getElementById('root'), ) ``` ##### TypeScript Migration and Support The React-Redux library source has always been written in plain JS, and the community maintained the TS typings separately as `@types/react-redux`. We've (finally!) [migrated the React-Redux codebase to TypeScript](https://togithub.com/reduxjs/react-redux/issues/1737), using the existing typings as a starting point. This means that **the `@types/react-redux` package is no longer needed, and you should remove that as a dependency**. > **Note** Please ensure that any installed copies of `redux` and `@types/react` are de-duped. You are also encouraged to update to the latest versions of Redux Toolkit (1.8.1+) or Redux (4.1.2), to ensure consistency between installed types and avoid problems from types mismatches. We've tried to maintain the same external type signatures as much as possible. If you do see any compile problems, please file issues with any apparent TS-related problems so we can review them. The TS migration was a great collaborative effort, with many community members contributing migrated files. Thank you to everyone who helped out! In addition to the "pre-typed" `TypedUseSelectorHook`, there's now also a `Connect` type that can be used as a "pre-typed" version of `connect` as well. As part of the process, we also updated the repo to use Yarn 3, copied the typetests files from DefinitelyTyped and expanded them, and improved our CI setup to test against multiple TS versions. ##### Removal of the `DefaultRootState` type The `@types/react-redux` package, which has always been maintained by the community, included a `DefaultRootState` interface that was intended for use with TS's "module augmentation" capability. Both `connect` and `useSelector` used this as a fallback if no state generic was provided. When we migrated React-Redux to TS, we copied over all of the types from that package as a starting point. However, the Redux team [specifically considers use of a globally augmented state type to be an anti-pattern](https://togithub.com/reduxjs/react-redux/issues/1879). Instead, we direct users to [extract the `RootState` and `AppDispatch` types from the store setup](https://redux.js.org/tutorials/typescript-quick-start#define-root-state-and-dispatch-types), and [create pre-typed versions of the React-Redux hooks](https://redux.js.org/tutorials/typescript-quick-start#define-typed-hooks) for use in the app. Now that React-Redux itself is written in TS, we've opted to remove the `DefaultRootState` type entirely. State generics now default to `unknown` instead. Technically [the module augmentation approach can still be done in userland](https://togithub.com/reduxjs/react-redux/issues/1879#issuecomment-1073284804), but we discourage this practice. ##### Modernized Build Output We've always targeted ES5 syntax in our published build artifacts as the lowest common denominator. Even the "ES module" artifacts with `import/export` keywords still were compiled to ES5 syntax otherwise. With IE11 now effectively dead and many sites no longer supporting it, we've updated our build tooling to target a more modern syntax equivalent to ES2017, which shrinks the bundle size slightly. If you still need to support ES5-only environments, please compile your own dependencies as needed for your target environment. ##### Removal of Legacy APIs We announced in 2019 that [the legacy `connectAdvanced` API would be removed in the next major version](https://togithub.com/reduxjs/react-redux/issues/1236), as it was rarely used, added internal complexity, and was also basically irrelevant with the introduction of hooks. As promised, we've removed that API. We've also removed the `pure` option for `connect`, which forced components to re-render regardless of whether props/state had actually changed if it was set to `false`. This option was needed in some cases in the early days of the React ecosystem, when components sometimes relied on external mutable data sources that could change outside of rendering. Today, no one writes components that way, the option was barely used, and React 18's `useSyncExternalStore` strictly requires immutable updates. So, we've removed the `pure` flag. Given that both of these options were almost never used, this shouldn't meaningfully affect anyone. #### Changes Due to the TS migration effort and number of contributors, this list covers just the major changes: - Integrate TypeScript port by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1739](https://togithub.com/reduxjs/react-redux/pull/1739) - Initial experimental React 18 compat prototyping by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1808](https://togithub.com/reduxjs/react-redux/pull/1808) - Fix compatibility with React 18 strict effects by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1817](https://togithub.com/reduxjs/react-redux/pull/1817) - Update to latest React 18 alpha dependencies by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1834](https://togithub.com/reduxjs/react-redux/pull/1834) - Port remaining v7 typetests and improve v8 types by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1855](https://togithub.com/reduxjs/react-redux/pull/1855) - Add initial SSR support for React 18 and React-Redux v8 by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1835](https://togithub.com/reduxjs/react-redux/pull/1835) - test: Adjust type tests to be compatible with React 18 typings by [@​eps1lon](https://togithub.com/eps1lon) in [https://github.com/reduxjs/react-redux/pull/1868](https://togithub.com/reduxjs/react-redux/pull/1868) - Switch back to Subscription in useSelector to fix unsubscribe perf by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1870](https://togithub.com/reduxjs/react-redux/pull/1870) - Cleanup more code after `pure` removal by [@​Andarist](https://togithub.com/Andarist) in [https://github.com/reduxjs/react-redux/pull/1859](https://togithub.com/reduxjs/react-redux/pull/1859) - Swap `useSyncExternalStore` shim behavior and update React deps by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1884](https://togithub.com/reduxjs/react-redux/pull/1884) - Remove `DefaultRootState` type by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1887](https://togithub.com/reduxjs/react-redux/pull/1887) - Add SSR test for `serverState` behavior by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1888](https://togithub.com/reduxjs/react-redux/pull/1888) - Cleanup internal types in selectorFactory.ts by [@​Methuselah96](https://togithub.com/Methuselah96) in [https://github.com/reduxjs/react-redux/pull/1889](https://togithub.com/reduxjs/react-redux/pull/1889) - Remove ts-ignore for initMergeProps by [@​Methuselah96](https://togithub.com/Methuselah96) in [https://github.com/reduxjs/react-redux/pull/1891](https://togithub.com/reduxjs/react-redux/pull/1891) - fix(deps): add optional peer deps into `peerDependencies` by [@​kyletsang](https://togithub.com/kyletsang) in [https://github.com/reduxjs/react-redux/pull/1893](https://togithub.com/reduxjs/react-redux/pull/1893) - Update peer deps for v8 by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1895](https://togithub.com/reduxjs/react-redux/pull/1895) - Port DT fix for `dispatchProp` arg in `mergeProps` by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1897](https://togithub.com/reduxjs/react-redux/pull/1897) - Update docs for v8 final by [@​markerikson](https://togithub.com/markerikson) in [https://github.com/reduxjs/react-redux/pull/1902](https://togithub.com/reduxjs/react-redux/pull/1902)
--- ### Configuration 📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone America/Los_Angeles. 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/valora-inc/wallet). --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jean Regisser --- jest.config.js | 2 +- package.json | 4 +- src/RevokePhoneNumber.tsx | 2 +- src/account/FiatExchange.tsx | 4 +- src/account/GoldEducation.tsx | 5 +-- src/account/Persona.tsx | 2 +- src/account/Profile.tsx | 4 +- src/account/Settings.tsx | 10 ++--- src/account/ShakeForSupport.tsx | 4 +- src/account/StoreWipeRecoveryScreen.tsx | 2 +- src/account/SupportContact.tsx | 2 +- src/alert/AlertBanner.tsx | 3 +- src/app/AppInitGate.tsx | 2 +- src/app/MultichainBeta.tsx | 2 +- src/app/useDeepLinks.ts | 3 +- src/backup/BackupComplete.tsx | 2 +- src/backup/utils.ts | 2 +- src/components/Avatar.tsx | 4 +- src/components/AvatarSelf.tsx | 2 +- src/components/ContactCircleSelf.tsx | 2 +- src/components/InviteOptionsModal.tsx | 6 +-- src/components/TokenBalance.tsx | 2 +- src/components/TokenDisplay.tsx | 2 +- .../ConsumerIncentivesHomeScreen.tsx | 3 +- src/dappkit/DappKitAccountScreen.tsx | 2 +- src/dappkit/DappKitSignTxScreen.tsx | 2 +- src/dapps/DappShortcutTransactionRequest.tsx | 2 +- src/dapps/DappShortcutsRewards.tsx | 4 +- .../DAppsExplorerScreenSearchFilter.tsx | 2 +- src/dappsExplorer/DappCard.tsx | 2 +- src/dappsExplorer/DappFeaturedActions.tsx | 2 +- src/dappsExplorer/DappRankingsBottomSheet.tsx | 2 +- src/dappsExplorer/NoResults.tsx | 2 +- src/dappsExplorer/useOpenDapp.tsx | 2 +- src/escrow/EscrowedPaymentListScreen.tsx | 2 +- src/escrow/ReclaimPaymentConfirmationCard.tsx | 4 +- .../ReclaimPaymentConfirmationScreen.tsx | 3 +- src/escrow/utils.ts | 2 +- src/exchange/CeloGoldHistoryChart.tsx | 2 +- src/exchange/CeloNewsFeed.tsx | 2 +- src/exchange/ExchangeHomeScreen.tsx | 2 +- src/fees/hooks.ts | 3 +- src/fiatExchanges/BidaliScreen.tsx | 2 +- src/fiatExchanges/CoinbasePaymentSection.tsx | 2 +- src/fiatExchanges/ExchangeQR.tsx | 2 +- src/fiatExchanges/FiatExchangeAmount.tsx | 2 +- .../FiatExchangeCurrencyBottomSheet.tsx | 2 +- src/fiatExchanges/PaymentMethodSection.tsx | 4 +- src/fiatExchanges/SelectProvider.tsx | 2 +- src/fiatExchanges/SimplexScreen.tsx | 2 +- src/fiatconnect/FiatDetailsScreen.tsx | 3 +- src/fiatconnect/KycLanding.tsx | 8 ++-- src/fiatconnect/RefetchQuoteScreen.tsx | 2 +- src/fiatconnect/ReviewScreen.tsx | 2 +- src/fiatconnect/TransferStatusScreen.tsx | 2 +- src/fiatconnect/kyc/KycDenied.tsx | 2 +- src/fiatconnect/kyc/KycExpired.tsx | 2 +- src/home/ActionsCarousel.tsx | 2 +- src/home/CashInBottomSheet.tsx | 2 +- src/home/DappsCarousel.tsx | 2 +- src/home/GetStarted.tsx | 2 +- src/home/NotificationBellSpotlight.tsx | 2 +- src/home/NotificationBox.tsx | 7 ++- src/home/NotificationCenter.tsx | 3 +- src/home/SendBar.tsx | 2 +- src/home/WalletHome.tsx | 3 +- src/home/celebration/NftCelebration.tsx | 2 +- src/home/useBalanceAutoRefresh.ts | 2 +- src/i18n/useChangeLanguage.ts | 2 +- src/import/ImportWallet.tsx | 9 ++-- src/invite/Invite.tsx | 4 +- src/invite/hooks.tsx | 2 +- src/jumpstart/JumpstartEnterAmount.tsx | 2 +- .../SelectJumpstartRecipientButton.tsx | 2 +- src/keylessBackup/KeylessBackupPhoneInput.tsx | 2 +- src/keylessBackup/KeylessBackupProgress.tsx | 2 +- src/keylessBackup/SignInWithEmail.tsx | 2 +- src/keylessBackup/hooks.ts | 2 +- src/localCurrency/SelectLocalCurrency.tsx | 4 +- src/localCurrency/hooks.ts | 2 +- src/navigator/DrawerNavigator.tsx | 3 +- src/navigator/Navigator.tsx | 1 - src/navigator/NavigatorWrapper.tsx | 13 +++--- src/navigator/QRNavigator.tsx | 2 +- src/navigator/RewardsPill.tsx | 2 +- src/nfts/NftGallery.tsx | 2 +- src/nfts/NftMedia.tsx | 2 +- src/onboarding/ChooseYourAdventure.tsx | 2 +- .../registration/EnableBiometry.tsx | 5 +-- src/onboarding/registration/ImportSelect.tsx | 2 +- .../registration/NameAndPicture.tsx | 9 ++-- .../registration/OnboardingRecoveryPhrase.tsx | 5 +-- src/onboarding/registration/PictureInput.tsx | 2 +- src/onboarding/registration/ProtectWallet.tsx | 5 +-- .../success/OnboardingSuccessScreen.tsx | 4 +- src/onboarding/welcome/Welcome.tsx | 3 +- src/pincode/PincodeEnter.tsx | 2 +- src/pincode/PincodeLock.tsx | 6 +-- src/positions/HooksPreviewModeBanner.tsx | 2 +- src/priceHistory/PriceHistoryChart.tsx | 3 +- src/qrcode/QRCode.tsx | 2 +- src/qrcode/QRTabBar.tsx | 2 +- src/recipients/RecipientItemV2.tsx | 4 +- src/redux/hooks.ts | 5 +++ src/redux/store.ts | 9 ++-- src/redux/useSelector.ts | 7 --- src/send/EnterAmount.tsx | 2 +- src/send/InviteRewardsCard.tsx | 2 +- src/send/SelectRecipientButtons.tsx | 2 +- src/send/SendConfirmation.tsx | 3 +- src/send/SendEnterAmount.tsx | 2 +- src/send/SendSelectRecipient.tsx | 3 +- src/send/ValidateRecipientIntro.tsx | 2 +- src/send/hooks.ts | 2 +- .../useFetchRecipientVerificationStatus.ts | 3 +- src/swap/SwapScreen.tsx | 3 +- src/swap/useFilterChips.ts | 2 +- src/swap/useSwapQuote.ts | 2 +- src/tokens/Assets.tsx | 3 +- src/tokens/TokenBalances.tsx | 2 +- src/tokens/TokenDetails.tsx | 2 +- src/tokens/TokenImport.tsx | 3 +- src/tokens/hooks.ts | 2 +- src/transactions/CommentSection.tsx | 2 +- src/transactions/feed/NftFeedItem.tsx | 2 +- src/transactions/feed/SwapFeedItem.tsx | 2 +- .../feed/TransactionDetailsScreen.tsx | 2 +- src/transactions/feed/TransactionFeed.tsx | 2 +- src/transactions/feed/TransferFeedItem.tsx | 2 +- .../detailContent/RewardReceivedContent.tsx | 2 +- .../detailContent/TransferReceivedContent.tsx | 6 +-- .../detailContent/TransferSentContent.tsx | 2 +- src/transactions/feed/queryHelper.ts | 2 +- src/transactions/transferFeedUtils.ts | 2 +- src/utils/countryFeatures.ts | 2 +- src/verify/VerificationStartScreen.tsx | 5 +-- src/verify/hooks.ts | 6 +-- src/walletConnect/screens/ActionRequest.tsx | 2 +- .../screens/ActionRequestPayload.tsx | 2 +- .../screens/EstimatedNetworkFee.tsx | 2 +- src/walletConnect/screens/RequestContent.tsx | 2 +- src/walletConnect/screens/SessionRequest.tsx | 2 +- src/walletConnect/screens/Sessions.tsx | 2 +- src/walletConnect/screens/useIsDappListed.ts | 2 +- src/webview/WebViewScreen.tsx | 4 +- yarn.lock | 45 ++++++++----------- 146 files changed, 216 insertions(+), 251 deletions(-) create mode 100644 src/redux/hooks.ts delete mode 100644 src/redux/useSelector.ts diff --git a/jest.config.js b/jest.config.js index 9aff8d58094..4092db308fe 100644 --- a/jest.config.js +++ b/jest.config.js @@ -44,6 +44,6 @@ module.exports = { '^.+\\.(txt)$': require.resolve('./node_modules/react-native/jest/assetFileTransformer.js'), }, transformIgnorePatterns: [ - 'node_modules/(?!(@celo/)?@?react-native|@react-navigation|@react-native-community|uuid|statsig-js|@react-native-firebase|react-navigation|redux-persist|date-fns|victory-*|@walletconnect/react-native-compat)', + 'node_modules/(?!(@celo/)?@?react-native|@react-navigation|@react-native-community|uuid|statsig-js|@react-native-firebase|react-navigation|redux-persist|date-fns|victory-*|@walletconnect/react-native-compat|react-redux)', ], } diff --git a/package.json b/package.json index a8daa49f113..ef2b63e7002 100644 --- a/package.json +++ b/package.json @@ -189,7 +189,7 @@ "react-native-url-polyfill": "^1.3.0", "react-native-video": "^6.0.0-beta.3", "react-native-webview": "^13.8.1", - "react-redux": "^7.2.9", + "react-redux": "^9.1.0", "redux": "^5.0.1", "redux-persist": "^6.0.0", "redux-persist-fs-storage": "^1.3.0", @@ -223,6 +223,7 @@ "@types/crypto-js": "^4.1.1", "@types/fast-levenshtein": "^0.0.2", "@types/fs-extra": "^9.0.13", + "@types/hoist-non-react-statics": "^3.3.5", "@types/isomorphic-fetch": "^0.0.35", "@types/jest": "^29.5.3", "@types/lodash": "^4.14.136", @@ -232,7 +233,6 @@ "@types/react-native-auth0": "^2.17.5", "@types/react-native-fs": "^2.13.0", "@types/react-native-video": "^5.0.15", - "@types/react-redux": "^7.1.7", "@types/react-test-renderer": "^18.0.0", "@types/redux-mock-store": "^1.0.6", "@types/seedrandom": "^3.0.5", diff --git a/src/RevokePhoneNumber.tsx b/src/RevokePhoneNumber.tsx index 474f24d8bab..e011f97a402 100644 --- a/src/RevokePhoneNumber.tsx +++ b/src/RevokePhoneNumber.tsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import { defaultCountryCodeSelector, e164NumberSelector } from 'src/account/selectors' import { SettingsEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -12,6 +11,7 @@ import ToastWithCTA from 'src/components/ToastWithCTA' import AttentionIcon from 'src/icons/Attention' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' +import { useSelector } from 'src/redux/hooks' import { Colors } from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/account/FiatExchange.tsx b/src/account/FiatExchange.tsx index ce0f62aa2bb..f8976876157 100644 --- a/src/account/FiatExchange.tsx +++ b/src/account/FiatExchange.tsx @@ -13,7 +13,7 @@ import { fiatExchange } from 'src/images/Images' import DrawerTopBar from 'src/navigator/DrawerTopBar' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useTypedSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' @@ -32,7 +32,7 @@ export function FiatExchangeSection({ showDrawerTopNav?: boolean }) { const [timestamp, setTimestamp] = useState(null) - const appState = useTypedSelector((state) => state.app.appState) + const appState = useSelector((state) => state.app.appState) useEffect(() => { if (appState === AppState.Active && timestamp) { diff --git a/src/account/GoldEducation.tsx b/src/account/GoldEducation.tsx index 8ed04210a41..8712566aeb5 100644 --- a/src/account/GoldEducation.tsx +++ b/src/account/GoldEducation.tsx @@ -1,9 +1,8 @@ import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { Platform } from 'react-native' -import { useDispatch } from 'react-redux' -import { setGoldEducationCompleted } from 'src/account/actions' import Education, { EducationTopic, EmbeddedNavBar } from 'src/account/Education' +import { setGoldEducationCompleted } from 'src/account/actions' import { celoEducationCompletedSelector } from 'src/account/selectors' import { OnboardingEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -12,7 +11,7 @@ import { celoEducation1, celoEducation2, celoEducation3, celoEducation4 } from ' import { noHeader } from 'src/navigator/Headers' import { navigate, navigateBack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' export default function GoldEducation() { const { t } = useTranslation() diff --git a/src/account/Persona.tsx b/src/account/Persona.tsx index 508b1ac23c3..c6a7eb8f581 100644 --- a/src/account/Persona.tsx +++ b/src/account/Persona.tsx @@ -3,7 +3,6 @@ import { useCallback, useState } from 'react' import { useAsync } from 'react-async-hook' import { useTranslation } from 'react-i18next' import { Fields, Inquiry } from 'react-native-persona' -import { useDispatch, useSelector } from 'react-redux' import { KycStatus } from 'src/account/reducer' import { showError } from 'src/alert/actions' import { CICOEvents } from 'src/analytics/Events' @@ -12,6 +11,7 @@ import { ErrorMessages } from 'src/app/ErrorMessages' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' import { getPersonaTemplateId } from 'src/firebase/firebase' import { createPersonaAccount, verifyWalletAddress } from 'src/in-house-liquidity' +import { useDispatch, useSelector } from 'src/redux/hooks' import Logger from 'src/utils/Logger' import networkConfig from 'src/web3/networkConfig' import { walletAddressSelector } from 'src/web3/selectors' diff --git a/src/account/Profile.tsx b/src/account/Profile.tsx index e4816286b80..1b4a2a4a32f 100644 --- a/src/account/Profile.tsx +++ b/src/account/Profile.tsx @@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import * as RNFS from 'react-native-fs' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { saveNameAndPicture } from 'src/account/actions' import { nameSelector, pictureSelector } from 'src/account/selectors' import { showError, showMessage } from 'src/alert/actions' @@ -24,11 +23,12 @@ import { emptyHeader } from 'src/navigator/Headers' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import PictureInput from 'src/onboarding/registration/PictureInput' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' -import { saveProfilePicture } from 'src/utils/image' import Logger from 'src/utils/Logger' +import { saveProfilePicture } from 'src/utils/image' type Props = NativeStackScreenProps diff --git a/src/account/Settings.tsx b/src/account/Settings.tsx index 353022526a7..d6372b0994a 100644 --- a/src/account/Settings.tsx +++ b/src/account/Settings.tsx @@ -12,7 +12,7 @@ import { View, } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' +import RevokePhoneNumber from 'src/RevokePhoneNumber' import { clearStoredAccount, devModeTriggerClicked, @@ -48,6 +48,8 @@ import { import BottomSheet, { BottomSheetRefType } from 'src/components/BottomSheet' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' import Dialog from 'src/components/Dialog' +import { Severity } from 'src/components/InLineNotification' +import InLineNotificationModal from 'src/components/InLineNotificationModal' import SectionHead from 'src/components/SectionHead' import SessionId from 'src/components/SessionId' import { @@ -72,19 +74,17 @@ import { ensurePincode, navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { removeStoredPin, setPincodeWithBiometry } from 'src/pincode/authentication' -import RevokePhoneNumber from 'src/RevokePhoneNumber' +import { useDispatch, useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig/index' import { StatsigFeatureGates } from 'src/statsig/types' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' -import { navigateToURI } from 'src/utils/linking' import Logger from 'src/utils/Logger' +import { navigateToURI } from 'src/utils/linking' import { useRevokeCurrentPhoneNumber } from 'src/verify/hooks' import { selectSessions } from 'src/walletConnect/selectors' import { walletAddressSelector } from 'src/web3/selectors' -import InLineNotificationModal from 'src/components/InLineNotificationModal' -import { Severity } from 'src/components/InLineNotification' type Props = NativeStackScreenProps diff --git a/src/account/ShakeForSupport.tsx b/src/account/ShakeForSupport.tsx index cc55f917086..31d58ac9fec 100644 --- a/src/account/ShakeForSupport.tsx +++ b/src/account/ShakeForSupport.tsx @@ -11,7 +11,7 @@ import Touchable from 'src/components/Touchable' import Times from 'src/icons/Times' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useTypedSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' @@ -19,7 +19,7 @@ import Logger from 'src/utils/Logger' export default function ShakeForSupport() { const { t } = useTranslation() - const appState = useTypedSelector(appStateSelector) + const appState = useSelector(appStateSelector) const [isVisible, setIsVisible] = React.useState(false) React.useEffect(() => { diff --git a/src/account/StoreWipeRecoveryScreen.tsx b/src/account/StoreWipeRecoveryScreen.tsx index 44c81aa5a2e..47c6e2abdc0 100644 --- a/src/account/StoreWipeRecoveryScreen.tsx +++ b/src/account/StoreWipeRecoveryScreen.tsx @@ -1,6 +1,5 @@ import React from 'react' import { useTranslation } from 'react-i18next' -import { useDispatch, useSelector } from 'react-redux' import AccountErrorScreen from 'src/account/AccountErrorScreen' import { startStoreWipeRecovery } from 'src/account/actions' import { recoveringFromStoreWipeSelector } from 'src/account/selectors' @@ -8,6 +7,7 @@ import { noHeaderGestureDisabled } from 'src/navigator/Headers' import { navigate } from 'src/navigator/NavigationService' import { firstOnboardingScreen } from 'src/onboarding/steps' import { requestPincodeInput } from 'src/pincode/authentication' +import { useDispatch, useSelector } from 'src/redux/hooks' import { getExperimentParams } from 'src/statsig' import { ExperimentConfigs } from 'src/statsig/constants' import { StatsigExperiments } from 'src/statsig/types' diff --git a/src/account/SupportContact.tsx b/src/account/SupportContact.tsx index b558a4350dd..1e3c048a2e1 100644 --- a/src/account/SupportContact.tsx +++ b/src/account/SupportContact.tsx @@ -4,7 +4,6 @@ import React, { useCallback, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, Platform, ScrollView, StyleSheet, Text, View } from 'react-native' import DeviceInfo from 'react-native-device-info' -import { useDispatch, useSelector } from 'react-redux' import { e164NumberSelector, nameSelector } from 'src/account/selectors' import { sendSupportRequest } from 'src/account/zendesk' import { showMessage } from 'src/alert/actions' @@ -24,6 +23,7 @@ import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { userLocationDataSelector } from 'src/networkInfo/selectors' import { hooksPreviewApiUrlSelector } from 'src/positions/selectors' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import Logger from 'src/utils/Logger' diff --git a/src/alert/AlertBanner.tsx b/src/alert/AlertBanner.tsx index 2492c185df4..c4194982196 100644 --- a/src/alert/AlertBanner.tsx +++ b/src/alert/AlertBanner.tsx @@ -1,12 +1,11 @@ import { noop } from 'lodash' import React, { memo, useMemo, useState } from 'react' import { StyleSheet, View } from 'react-native' -import { useDispatch } from 'react-redux' import { AlertTypes, hideAlert } from 'src/alert/actions' import { Alert, ErrorDisplayType } from 'src/alert/reducer' import SmartTopAlert from 'src/components/SmartTopAlert' import ToastWithCTA from 'src/components/ToastWithCTA' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' function AlertBanner() { const [toastAlert, setToastAlert] = useState<(Alert & { isActive: boolean }) | null>(null) diff --git a/src/app/AppInitGate.tsx b/src/app/AppInitGate.tsx index 45b40772772..b77fb6f00df 100644 --- a/src/app/AppInitGate.tsx +++ b/src/app/AppInitGate.tsx @@ -3,7 +3,6 @@ import React, { useEffect } from 'react' import { useAsync } from 'react-async-hook' import { Dimensions } from 'react-native' import { findBestAvailableLanguage } from 'react-native-localize' -import { useDispatch, useSelector } from 'react-redux' import { AppEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { appMounted, appUnmounted } from 'src/app/actions' @@ -12,6 +11,7 @@ import i18n from 'src/i18n' import { currentLanguageSelector } from 'src/i18n/selectors' import useChangeLanguage from 'src/i18n/useChangeLanguage' import { navigateToError } from 'src/navigator/NavigationService' +import { useDispatch, useSelector } from 'src/redux/hooks' import { waitUntilSagasFinishLoading } from 'src/redux/sagas' import Logger from 'src/utils/Logger' diff --git a/src/app/MultichainBeta.tsx b/src/app/MultichainBeta.tsx index 2bfb6ff47d3..2f76e466cf5 100644 --- a/src/app/MultichainBeta.tsx +++ b/src/app/MultichainBeta.tsx @@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import { ScrollView } from 'react-native-gesture-handler' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { AppEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { MultichainBetaStatus, optMultichainBeta } from 'src/app/actions' @@ -15,6 +14,7 @@ import i18n from 'src/i18n' import { emptyHeader } from 'src/navigator/Headers' import { navigate, navigateHome } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' +import { useDispatch, useSelector } from 'src/redux/hooks' import { patchUpdateStatsigUser } from 'src/statsig' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' diff --git a/src/app/useDeepLinks.ts b/src/app/useDeepLinks.ts index 0d89910d233..5c8fcb042a5 100644 --- a/src/app/useDeepLinks.ts +++ b/src/app/useDeepLinks.ts @@ -3,12 +3,11 @@ import CleverTap from 'clevertap-react-native' import { useEffect, useState } from 'react' import { useAsync } from 'react-async-hook' import { Linking, Platform } from 'react-native' -import { useDispatch } from 'react-redux' import { deepLinkDeferred, openDeepLink } from 'src/app/actions' import { pendingDeepLinkSelector } from 'src/app/selectors' import { DYNAMIC_LINK_DOMAIN_URI_PREFIX, FIREBASE_ENABLED } from 'src/config' import { hasVisitedHomeSelector } from 'src/home/selectors' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import Logger from 'src/utils/Logger' import { walletAddressSelector } from 'src/web3/selectors' diff --git a/src/backup/BackupComplete.tsx b/src/backup/BackupComplete.tsx index a92de4c6d67..8a6df46cc6f 100644 --- a/src/backup/BackupComplete.tsx +++ b/src/backup/BackupComplete.tsx @@ -10,7 +10,7 @@ import Checkmark from 'src/icons/Checkmark' import { navigate, navigateHome } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import fontStyles from 'src/styles/fonts' /** diff --git a/src/backup/utils.ts b/src/backup/utils.ts index 5f77a6e797a..dfdea1f17cb 100644 --- a/src/backup/utils.ts +++ b/src/backup/utils.ts @@ -6,12 +6,12 @@ import { import CryptoJS from 'crypto-js' import { useAsync } from 'react-async-hook' import * as bip39 from 'react-native-bip39' -import { useDispatch, useSelector } from 'react-redux' import { showError } from 'src/alert/actions' import { OnboardingEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { ErrorMessages } from 'src/app/ErrorMessages' import { getPassword } from 'src/pincode/authentication' +import { useDispatch, useSelector } from 'src/redux/hooks' import { removeStoredItem, retrieveStoredItem, storeItem } from 'src/storage/keychain' import Logger from 'src/utils/Logger' import { ETHEREUM_DERIVATION_PATH } from 'src/web3/consts' diff --git a/src/components/Avatar.tsx b/src/components/Avatar.tsx index f4e468b12c1..42c77aa2ebf 100644 --- a/src/components/Avatar.tsx +++ b/src/components/Avatar.tsx @@ -1,13 +1,13 @@ import * as React from 'react' import { WithTranslation } from 'react-i18next' import { StyleSheet, Text, TextStyle, View } from 'react-native' -import { useSelector } from 'react-redux' import { defaultCountryCodeSelector } from 'src/account/selectors' import ContactCircle from 'src/components/ContactCircle' import PhoneNumberWithFlag from 'src/components/PhoneNumberWithFlag' import { formatShortenedAddress } from 'src/components/ShortenedAddress' import { withTranslation } from 'src/i18n' -import { getDisplayName, Recipient } from 'src/recipients/recipient' +import { Recipient, getDisplayName } from 'src/recipients/recipient' +import { useSelector } from 'src/redux/hooks' import fontStyles from 'src/styles/fonts' const DEFAULT_ICON_SIZE = 40 diff --git a/src/components/AvatarSelf.tsx b/src/components/AvatarSelf.tsx index da380b76578..3bd7e7cd29f 100644 --- a/src/components/AvatarSelf.tsx +++ b/src/components/AvatarSelf.tsx @@ -3,7 +3,7 @@ import { TextStyle } from 'react-native' import { e164NumberSelector, nameSelector, userContactDetailsSelector } from 'src/account/selectors' import Avatar from 'src/components/Avatar' import { Recipient, RecipientType } from 'src/recipients/recipient' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { currentAccountSelector } from 'src/web3/selectors' interface Props { diff --git a/src/components/ContactCircleSelf.tsx b/src/components/ContactCircleSelf.tsx index 82a80ac51da..47db66d7d06 100644 --- a/src/components/ContactCircleSelf.tsx +++ b/src/components/ContactCircleSelf.tsx @@ -1,9 +1,9 @@ import * as React from 'react' import { ViewStyle } from 'react-native' -import { useSelector } from 'react-redux' import { currentUserRecipientSelector } from 'src/account/selectors' import ContactCircle from 'src/components/ContactCircle' import { Recipient } from 'src/recipients/recipient' +import { useSelector } from 'src/redux/hooks' interface Props { style?: ViewStyle size?: number diff --git a/src/components/InviteOptionsModal.tsx b/src/components/InviteOptionsModal.tsx index f29bb881b8e..80fc69cad1b 100644 --- a/src/components/InviteOptionsModal.tsx +++ b/src/components/InviteOptionsModal.tsx @@ -2,14 +2,14 @@ import getPhoneHash from '@celo/phone-utils/lib/getPhoneHash' import * as React from 'react' import { useTranslation } from 'react-i18next' import { Share } from 'react-native' -import { useSelector } from 'react-redux' import { InviteEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { INVITE_REWARDS_NFTS_LEARN_MORE, INVITE_REWARDS_STABLETOKEN_LEARN_MORE } from 'src/config' import { inviteModal } from 'src/images/Images' -import { useShareUrl } from 'src/invite/hooks' import InviteModal from 'src/invite/InviteModal' -import { getDisplayName, Recipient } from 'src/recipients/recipient' +import { useShareUrl } from 'src/invite/hooks' +import { Recipient, getDisplayName } from 'src/recipients/recipient' +import { useSelector } from 'src/redux/hooks' import { inviteRewardsActiveSelector, inviteRewardsTypeSelector } from 'src/send/selectors' import { InviteRewardsType } from 'src/send/types' diff --git a/src/components/TokenBalance.tsx b/src/components/TokenBalance.tsx index 41b2dbeaca1..fe6c35afa1a 100644 --- a/src/components/TokenBalance.tsx +++ b/src/components/TokenBalance.tsx @@ -13,7 +13,6 @@ import { } from 'react-native' import { getNumberFormatSettings } from 'react-native-localize' import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated' -import { useDispatch, useSelector } from 'react-redux' import { hideAlert, showToast } from 'src/alert/actions' import { AssetsEvents, FiatExchangeEvents, HomeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -36,6 +35,7 @@ import { import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { totalPositionsBalanceUsdSelector } from 'src/positions/selectors' +import { useDispatch, useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import Colors from 'src/styles/colors' diff --git a/src/components/TokenDisplay.tsx b/src/components/TokenDisplay.tsx index 7bc55e7d458..36aee7352ca 100644 --- a/src/components/TokenDisplay.tsx +++ b/src/components/TokenDisplay.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import { StyleProp, Text, TextStyle } from 'react-native' import { LocalCurrencyCode, LocalCurrencySymbol } from 'src/localCurrency/consts' import { getLocalCurrencySymbol, usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { useTokenInfo } from 'src/tokens/hooks' import { LocalAmount } from 'src/transactions/types' diff --git a/src/consumerIncentives/ConsumerIncentivesHomeScreen.tsx b/src/consumerIncentives/ConsumerIncentivesHomeScreen.tsx index f5567055e1d..e5b7aa0d672 100644 --- a/src/consumerIncentives/ConsumerIncentivesHomeScreen.tsx +++ b/src/consumerIncentives/ConsumerIncentivesHomeScreen.tsx @@ -3,7 +3,6 @@ import React, { useEffect, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { ActivityIndicator, Image, ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { showError } from 'src/alert/actions' import { RewardsEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -36,7 +35,7 @@ import { noHeader } from 'src/navigator/Headers' import { navigate, navigateBack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { userLocationDataSelector } from 'src/networkInfo/selectors' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import colors from 'src/styles/colors' diff --git a/src/dappkit/DappKitAccountScreen.tsx b/src/dappkit/DappKitAccountScreen.tsx index 06ad5e17c28..271239c87b3 100644 --- a/src/dappkit/DappKitAccountScreen.tsx +++ b/src/dappkit/DappKitAccountScreen.tsx @@ -1,7 +1,6 @@ import { BottomSheetScreenProps } from '@th3rdwave/react-navigation-bottom-sheet' import React from 'react' import { useTranslation } from 'react-i18next' -import { useDispatch, useSelector } from 'react-redux' import { e164NumberSelector } from 'src/account/selectors' import { DappKitEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -11,6 +10,7 @@ import { activeDappSelector } from 'src/dapps/selectors' import { isBottomSheetVisible, navigateBack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import { SentryTransactionHub } from 'src/sentry/SentryTransactionHub' import { SentryTransaction } from 'src/sentry/SentryTransactions' import Logger from 'src/utils/Logger' diff --git a/src/dappkit/DappKitSignTxScreen.tsx b/src/dappkit/DappKitSignTxScreen.tsx index c56fec5717c..8c8ba74b3ca 100644 --- a/src/dappkit/DappKitSignTxScreen.tsx +++ b/src/dappkit/DappKitSignTxScreen.tsx @@ -4,7 +4,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import Toast from 'react-native-simple-toast' -import { useDispatch, useSelector } from 'react-redux' import { DappKitEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import BottomSheetScrollView from 'src/components/BottomSheetScrollView' @@ -15,6 +14,7 @@ import CopyIcon from 'src/icons/CopyIcon' import { isBottomSheetVisible, navigateBack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { vibrateInformative } from 'src/styles/hapticFeedback' diff --git a/src/dapps/DappShortcutTransactionRequest.tsx b/src/dapps/DappShortcutTransactionRequest.tsx index 023f3b062bc..2984b56381f 100644 --- a/src/dapps/DappShortcutTransactionRequest.tsx +++ b/src/dapps/DappShortcutTransactionRequest.tsx @@ -2,7 +2,6 @@ import { BottomSheetScreenProps } from '@th3rdwave/react-navigation-bottom-sheet import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, StyleSheet } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import { DappShortcutsEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import BottomSheetScrollView from 'src/components/BottomSheetScrollView' @@ -11,6 +10,7 @@ import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { triggeredShortcutsStatusSelector } from 'src/positions/selectors' import { denyExecuteShortcut, executeShortcut } from 'src/positions/slice' +import { useDispatch, useSelector } from 'src/redux/hooks' import { Colors } from 'src/styles/colors' import { Spacing } from 'src/styles/styles' import Logger from 'src/utils/Logger' diff --git a/src/dapps/DappShortcutsRewards.tsx b/src/dapps/DappShortcutsRewards.tsx index fbfb866e94e..3c10a6ba54f 100644 --- a/src/dapps/DappShortcutsRewards.tsx +++ b/src/dapps/DappShortcutsRewards.tsx @@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next' import { Image, StyleSheet, Text, View } from 'react-native' import Animated from 'react-native-reanimated' import { useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { DappShortcutsEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes } from 'src/components/Button' @@ -17,11 +16,12 @@ import { } from 'src/positions/selectors' import { triggerShortcut } from 'src/positions/slice' import { ClaimablePosition } from 'src/positions/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import Colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' -import { Currency } from 'src/utils/currencies' import Logger from 'src/utils/Logger' +import { Currency } from 'src/utils/currencies' import { walletAddressSelector } from 'src/web3/selectors' function DappShortcutsRewards() { diff --git a/src/dappsExplorer/DAppsExplorerScreenSearchFilter.tsx b/src/dappsExplorer/DAppsExplorerScreenSearchFilter.tsx index f915796dd89..d2db1cb7832 100644 --- a/src/dappsExplorer/DAppsExplorerScreenSearchFilter.tsx +++ b/src/dappsExplorer/DAppsExplorerScreenSearchFilter.tsx @@ -4,7 +4,6 @@ import { RefreshControl, SectionList, SectionListProps, StyleSheet, Text, View } import { ScrollView } from 'react-native-gesture-handler' import Animated from 'react-native-reanimated' import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { DappExplorerEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { BottomSheetRefType } from 'src/components/BottomSheet' @@ -30,6 +29,7 @@ import useOpenDapp from 'src/dappsExplorer/useOpenDapp' import { currentLanguageSelector } from 'src/i18n/selectors' import DrawerTopBar from 'src/navigator/DrawerTopBar' import { styles as headerStyles } from 'src/navigator/Headers' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/dappsExplorer/DappCard.tsx b/src/dappsExplorer/DappCard.tsx index fc721c30955..f8345233893 100644 --- a/src/dappsExplorer/DappCard.tsx +++ b/src/dappsExplorer/DappCard.tsx @@ -1,6 +1,5 @@ import React from 'react' import { Image, StyleSheet, Text, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import { DappExplorerEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Card from 'src/components/Card' @@ -10,6 +9,7 @@ import { favoriteDapp, unfavoriteDapp } from 'src/dapps/slice' import { Dapp, DappSection } from 'src/dapps/types' import Star from 'src/icons/Star' import StarOutline from 'src/icons/StarOutline' +import { useDispatch, useSelector } from 'src/redux/hooks' import { Colors } from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { vibrateSuccess } from 'src/styles/hapticFeedback' diff --git a/src/dappsExplorer/DappFeaturedActions.tsx b/src/dappsExplorer/DappFeaturedActions.tsx index e390e8018c1..9c6bcc1b27e 100644 --- a/src/dappsExplorer/DappFeaturedActions.tsx +++ b/src/dappsExplorer/DappFeaturedActions.tsx @@ -2,7 +2,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native' import { ScrollView } from 'react-native-gesture-handler' -import { useSelector } from 'react-redux' import Touchable from 'src/components/Touchable' import { mostPopularDappsSelector } from 'src/dapps/selectors' import Trophy from 'src/icons/Trophy' @@ -10,6 +9,7 @@ import Wallet from 'src/icons/Wallet' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { positionsWithClaimableRewardsSelector } from 'src/positions/selectors' +import { useSelector } from 'src/redux/hooks' import { getExperimentParams, getFeatureGate } from 'src/statsig' import { ExperimentConfigs } from 'src/statsig/constants' import { StatsigExperiments, StatsigFeatureGates } from 'src/statsig/types' diff --git a/src/dappsExplorer/DappRankingsBottomSheet.tsx b/src/dappsExplorer/DappRankingsBottomSheet.tsx index e9ffaa388d5..5ab73ba7cf4 100644 --- a/src/dappsExplorer/DappRankingsBottomSheet.tsx +++ b/src/dappsExplorer/DappRankingsBottomSheet.tsx @@ -2,12 +2,12 @@ import React, { RefObject } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import Toast from 'react-native-simple-toast' -import { useSelector } from 'react-redux' import BottomSheet, { BottomSheetRefType } from 'src/components/BottomSheet' import Touchable from 'src/components/Touchable' import { mostPopularDappsSelector } from 'src/dapps/selectors' import { ActiveDapp, Dapp, DappSection } from 'src/dapps/types' import { DappCardContent } from 'src/dappsExplorer/DappCard' +import { useSelector } from 'src/redux/hooks' import { Colors } from 'src/styles/colors' import fontStyles from 'src/styles/fonts' diff --git a/src/dappsExplorer/NoResults.tsx b/src/dappsExplorer/NoResults.tsx index 397d6f344c1..3765c6596cc 100644 --- a/src/dappsExplorer/NoResults.tsx +++ b/src/dappsExplorer/NoResults.tsx @@ -1,12 +1,12 @@ import React from 'react' import { Trans, useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import { FilterChip } from 'src/components/FilterChipsCarousel' import Touchable from 'src/components/Touchable' import { DappWithCategoryNames } from 'src/dapps/types' import { currentLanguageSelector } from 'src/i18n/selectors' import InfoIcon from 'src/icons/InfoIcon' +import { useSelector } from 'src/redux/hooks' import Colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/dappsExplorer/useOpenDapp.tsx b/src/dappsExplorer/useOpenDapp.tsx index 3478873880c..cbca130f59f 100644 --- a/src/dappsExplorer/useOpenDapp.tsx +++ b/src/dappsExplorer/useOpenDapp.tsx @@ -1,5 +1,4 @@ import { Keyboard } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import { DappExplorerEvents } from 'src/analytics/Events' import { AnalyticsPropertiesList } from 'src/analytics/Properties' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -8,6 +7,7 @@ import { recentDappsSelector } from 'src/dapps/selectors' import { dappSelected } from 'src/dapps/slice' import { ActiveDapp } from 'src/dapps/types' import { Screens } from 'src/navigator/Screens' +import { useDispatch, useSelector } from 'src/redux/hooks' type ExtraAnalyticsProperties = Partial diff --git a/src/escrow/EscrowedPaymentListScreen.tsx b/src/escrow/EscrowedPaymentListScreen.tsx index 8e406ce7e9f..a8aa215e4fc 100644 --- a/src/escrow/EscrowedPaymentListScreen.tsx +++ b/src/escrow/EscrowedPaymentListScreen.tsx @@ -8,7 +8,7 @@ import { NotificationList, titleWithBalanceNavigationOptions, } from 'src/notifications/NotificationList' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { Spacing } from 'src/styles/styles' export const listItemRenderer = (payment: EscrowedPayment, key: number | undefined = undefined) => { diff --git a/src/escrow/ReclaimPaymentConfirmationCard.tsx b/src/escrow/ReclaimPaymentConfirmationCard.tsx index 9fdc4d1ce9b..9e198bcf6a1 100644 --- a/src/escrow/ReclaimPaymentConfirmationCard.tsx +++ b/src/escrow/ReclaimPaymentConfirmationCard.tsx @@ -5,13 +5,13 @@ import { StyleSheet, View } from 'react-native' import Avatar from 'src/components/Avatar' import { SecurityFeeIcon } from 'src/components/FeeIcon' import HorizontalLine from 'src/components/HorizontalLine' -import LineItemRow from 'src/components/LineItemRow' import LegacyTokenDisplay from 'src/components/LegacyTokenDisplay' import LegacyTokenTotalLineItem from 'src/components/LegacyTokenTotalLineItem' +import LineItemRow from 'src/components/LineItemRow' import { FeeType } from 'src/fees/reducer' import { feeEstimatesSelector } from 'src/fees/selectors' import { MobileRecipient } from 'src/recipients/recipient' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { useTokenInfoByAddress, useUsdToTokenAmount } from 'src/tokens/hooks' import { celoAddressSelector } from 'src/tokens/selectors' import { divideByWei } from 'src/utils/formatting' diff --git a/src/escrow/ReclaimPaymentConfirmationScreen.tsx b/src/escrow/ReclaimPaymentConfirmationScreen.tsx index 6299d57fefc..b063b82131f 100644 --- a/src/escrow/ReclaimPaymentConfirmationScreen.tsx +++ b/src/escrow/ReclaimPaymentConfirmationScreen.tsx @@ -5,7 +5,6 @@ import { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, StyleSheet } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { showError } from 'src/alert/actions' import { EscrowEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -20,8 +19,8 @@ import { navigateBack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { RecipientType } from 'src/recipients/recipient' +import { useDispatch, useSelector } from 'src/redux/hooks' import { isAppConnected } from 'src/redux/selectors' -import useSelector from 'src/redux/useSelector' import DisconnectBanner from 'src/shared/DisconnectBanner' import colors from 'src/styles/colors' import Logger from 'src/utils/Logger' diff --git a/src/escrow/utils.ts b/src/escrow/utils.ts index 602fb125e8b..04cc84ce4f3 100644 --- a/src/escrow/utils.ts +++ b/src/escrow/utils.ts @@ -1,7 +1,7 @@ import { EscrowedPayment } from 'src/escrow/actions' import { identifierToE164NumberSelector } from 'src/identity/selectors' import { ContactRecipient } from 'src/recipients/recipient' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' export const useEscrowPaymentRecipient = (payment: EscrowedPayment): ContactRecipient => { const { recipientPhone, recipientIdentifier } = payment diff --git a/src/exchange/CeloGoldHistoryChart.tsx b/src/exchange/CeloGoldHistoryChart.tsx index 6390112da52..20f5f00f254 100644 --- a/src/exchange/CeloGoldHistoryChart.tsx +++ b/src/exchange/CeloGoldHistoryChart.tsx @@ -18,7 +18,7 @@ import { withTranslation } from 'src/i18n' import { LocalCurrencyCode } from 'src/localCurrency/consts' import { convertDollarsToLocalAmount } from 'src/localCurrency/convert' import { getLocalCurrencyCode, usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import { Spacing } from 'src/styles/styles' import variables from 'src/styles/variables' diff --git a/src/exchange/CeloNewsFeed.tsx b/src/exchange/CeloNewsFeed.tsx index 3847c45da7a..6360e51c64e 100644 --- a/src/exchange/CeloNewsFeed.tsx +++ b/src/exchange/CeloNewsFeed.tsx @@ -11,7 +11,7 @@ import CeloNewsFeedItem from 'src/exchange/CeloNewsFeedItem' import { CeloNewsArticle, CeloNewsArticles } from 'src/exchange/types' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/exchange/ExchangeHomeScreen.tsx b/src/exchange/ExchangeHomeScreen.tsx index f45a25e5181..a5db1e461c2 100644 --- a/src/exchange/ExchangeHomeScreen.tsx +++ b/src/exchange/ExchangeHomeScreen.tsx @@ -18,7 +18,7 @@ import DrawerTopBar from 'src/navigator/DrawerTopBar' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import PriceHistoryChart from 'src/priceHistory/PriceHistoryChart' -import { default as useSelector } from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import DisconnectBanner from 'src/shared/DisconnectBanner' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' diff --git a/src/fees/hooks.ts b/src/fees/hooks.ts index f0869c177b4..f15578704bf 100644 --- a/src/fees/hooks.ts +++ b/src/fees/hooks.ts @@ -1,10 +1,9 @@ import BigNumber from 'bignumber.js' import { useEffect } from 'react' -import { useDispatch } from 'react-redux' import { FeeType, estimateFee } from 'src/fees/reducer' import { fetchFeeCurrency } from 'src/fees/saga' import { feeEstimatesSelector } from 'src/fees/selectors' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { useTokenInfo, useUsdToTokenAmount } from 'src/tokens/hooks' import { celoAddressSelector, tokensByUsdBalanceSelector } from 'src/tokens/selectors' import { ONE_HOUR_IN_MILLIS } from 'src/utils/time' diff --git a/src/fiatExchanges/BidaliScreen.tsx b/src/fiatExchanges/BidaliScreen.tsx index 71641fa3d7b..96a0dc26a4b 100644 --- a/src/fiatExchanges/BidaliScreen.tsx +++ b/src/fiatExchanges/BidaliScreen.tsx @@ -3,7 +3,6 @@ import React, { useEffect, useMemo, useRef, useState } from 'react' import { ActivityIndicator, StyleSheet } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' import { WebViewMessageEvent } from 'react-native-webview' -import { useDispatch, useSelector } from 'react-redux' import { createSelector } from 'reselect' import { e164NumberSelector } from 'src/account/selectors' import { openUrl } from 'src/app/actions' @@ -15,6 +14,7 @@ import { navigateBack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { TopBarTextButton } from 'src/navigator/TopBarButton' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import { tokensByCurrencySelector } from 'src/tokens/selectors' import { getHigherBalanceCurrency } from 'src/tokens/utils' diff --git a/src/fiatExchanges/CoinbasePaymentSection.tsx b/src/fiatExchanges/CoinbasePaymentSection.tsx index 15af92e79f5..ec7c0e4b790 100644 --- a/src/fiatExchanges/CoinbasePaymentSection.tsx +++ b/src/fiatExchanges/CoinbasePaymentSection.tsx @@ -3,7 +3,6 @@ import React from 'react' import { generateOnRampURL } from '@coinbase/cbpay-js' import { useTranslation } from 'react-i18next' import { Image, StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import { CoinbasePayEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Touchable from 'src/components/Touchable' @@ -11,6 +10,7 @@ import { ProviderSelectionAnalyticsData } from 'src/fiatExchanges/types' import { FetchProvidersOutput } from 'src/fiatExchanges/utils' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { useTokenInfo } from 'src/tokens/hooks' diff --git a/src/fiatExchanges/ExchangeQR.tsx b/src/fiatExchanges/ExchangeQR.tsx index 8ce69fdd7f3..8d1663163d4 100644 --- a/src/fiatExchanges/ExchangeQR.tsx +++ b/src/fiatExchanges/ExchangeQR.tsx @@ -1,7 +1,6 @@ import { RouteProp } from '@react-navigation/native' import { NativeStackScreenProps } from '@react-navigation/native-stack' import React, { useLayoutEffect, useRef } from 'react' -import { useDispatch } from 'react-redux' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import BackButton from 'src/components/BackButton' @@ -13,6 +12,7 @@ import { Screens } from 'src/navigator/Screens' import { TopBarIconButton } from 'src/navigator/TopBarButton' import { StackParamList } from 'src/navigator/types' import QRCode from 'src/qrcode/QRCode' +import { useDispatch } from 'src/redux/hooks' import { SVG, shareQRCode } from 'src/send/actions' import { CICOFlow } from './utils' diff --git a/src/fiatExchanges/FiatExchangeAmount.tsx b/src/fiatExchanges/FiatExchangeAmount.tsx index 3525d9ca024..650082b44e1 100644 --- a/src/fiatExchanges/FiatExchangeAmount.tsx +++ b/src/fiatExchanges/FiatExchangeAmount.tsx @@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next' import { Platform, StyleSheet, Text, TextInput, View } from 'react-native' import { getNumberFormatSettings } from 'react-native-localize' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { showError } from 'src/alert/actions' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -34,6 +33,7 @@ import { HeaderTitleWithTokenBalance, emptyHeader } from 'src/navigator/Headers' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import DisconnectBanner from 'src/shared/DisconnectBanner' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' diff --git a/src/fiatExchanges/FiatExchangeCurrencyBottomSheet.tsx b/src/fiatExchanges/FiatExchangeCurrencyBottomSheet.tsx index 05fbe507b29..d43e91bd4f3 100644 --- a/src/fiatExchanges/FiatExchangeCurrencyBottomSheet.tsx +++ b/src/fiatExchanges/FiatExchangeCurrencyBottomSheet.tsx @@ -2,12 +2,12 @@ import { BottomSheetScreenProps } from '@th3rdwave/react-navigation-bottom-sheet import React, { useEffect, useMemo } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text } from 'react-native' -import { useDispatch } from 'react-redux' import BottomSheetScrollView from 'src/components/BottomSheetScrollView' import { fetchFiatConnectProviders } from 'src/fiatconnect/slice' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch } from 'src/redux/hooks' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' import { TokenBalanceItem } from 'src/tokens/TokenBalanceItem' diff --git a/src/fiatExchanges/PaymentMethodSection.tsx b/src/fiatExchanges/PaymentMethodSection.tsx index 6587e0ee25e..bb328c0b3d0 100644 --- a/src/fiatExchanges/PaymentMethodSection.tsx +++ b/src/fiatExchanges/PaymentMethodSection.tsx @@ -1,20 +1,20 @@ import React, { useEffect, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { Image, LayoutAnimation, StyleSheet, Text, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Dialog from 'src/components/Dialog' import Expandable from 'src/components/Expandable' import Touchable from 'src/components/Touchable' import { CryptoAmount, FiatAmount } from 'src/fiatExchanges/amount' -import { SettlementEstimation, SettlementTime } from 'src/fiatExchanges/quotes/constants' import NormalizedQuote from 'src/fiatExchanges/quotes/NormalizedQuote' +import { SettlementEstimation, SettlementTime } from 'src/fiatExchanges/quotes/constants' import { getSettlementTimeString } from 'src/fiatExchanges/quotes/utils' import { ProviderSelectionAnalyticsData } from 'src/fiatExchanges/types' import { CICOFlow, PaymentMethod } from 'src/fiatExchanges/utils' import InfoIcon from 'src/icons/InfoIcon' import { getLocalCurrencyCode, usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { useTokenInfo } from 'src/tokens/hooks' diff --git a/src/fiatExchanges/SelectProvider.tsx b/src/fiatExchanges/SelectProvider.tsx index c02713734d1..d04b4e8e1d2 100644 --- a/src/fiatExchanges/SelectProvider.tsx +++ b/src/fiatExchanges/SelectProvider.tsx @@ -5,7 +5,6 @@ import React, { useEffect, useMemo, useState } from 'react' import { useAsync } from 'react-async-hook' import { Trans, useTranslation } from 'react-i18next' import { ActivityIndicator, ScrollView, StyleSheet, Text, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import { showError } from 'src/alert/actions' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -48,6 +47,7 @@ import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { userLocationDataSelector } from 'src/networkInfo/selectors' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/fiatExchanges/SimplexScreen.tsx b/src/fiatExchanges/SimplexScreen.tsx index 4ca2d161ff3..b982c217b03 100644 --- a/src/fiatExchanges/SimplexScreen.tsx +++ b/src/fiatExchanges/SimplexScreen.tsx @@ -3,7 +3,6 @@ import React, { useLayoutEffect, useState } from 'react' import { useAsync } from 'react-async-hook' import { useTranslation } from 'react-i18next' import { ActivityIndicator, StyleSheet, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import { e164NumberSelector } from 'src/account/selectors' import { showError } from 'src/alert/actions' import { FiatExchangeEvents } from 'src/analytics/Events' @@ -22,6 +21,7 @@ import { HeaderTitleWithBalance, emptyHeader } from 'src/navigator/Headers' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { userLocationDataSelector } from 'src/networkInfo/selectors' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import { useTokenInfo } from 'src/tokens/hooks' import { resolveCurrency } from 'src/utils/currencies' diff --git a/src/fiatconnect/FiatDetailsScreen.tsx b/src/fiatconnect/FiatDetailsScreen.tsx index d3c3e8a8176..ffc52fefe53 100644 --- a/src/fiatconnect/FiatDetailsScreen.tsx +++ b/src/fiatconnect/FiatDetailsScreen.tsx @@ -5,7 +5,6 @@ import { useTranslation } from 'react-i18next' import { ActivityIndicator, Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native' import PickerSelect from 'react-native-picker-select' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import BackButton from 'src/components/BackButton' @@ -34,7 +33,7 @@ import { navigateHome } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { userLocationDataSelector } from 'src/networkInfo/selectors' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' diff --git a/src/fiatconnect/KycLanding.tsx b/src/fiatconnect/KycLanding.tsx index b8c764513d1..017f96d0e7a 100644 --- a/src/fiatconnect/KycLanding.tsx +++ b/src/fiatconnect/KycLanding.tsx @@ -13,24 +13,24 @@ import { TouchableOpacity, View, } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import Persona from 'src/account/Persona' import { KycStatus } from 'src/account/reducer' import { CICOEvents, FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { PRIVACY_LINK } from 'src/brandingConfig' import BackButton from 'src/components/BackButton' -import { getTranslationStrings, LinkAccountSection } from 'src/fiatconnect/LinkAccountScreen' -import { personaInProgressSelector } from 'src/fiatconnect/selectors' -import { personaFinished, personaStarted, postKyc } from 'src/fiatconnect/slice' import FiatConnectQuote from 'src/fiatExchanges/quotes/FiatConnectQuote' import { CICOFlow } from 'src/fiatExchanges/utils' +import { LinkAccountSection, getTranslationStrings } from 'src/fiatconnect/LinkAccountScreen' +import { personaInProgressSelector } from 'src/fiatconnect/selectors' +import { personaFinished, personaStarted, postKyc } from 'src/fiatconnect/slice' import i18n from 'src/i18n' import CheckBox from 'src/icons/CheckBox' import GreyOut from 'src/icons/GreyOut' import { emptyHeader } from 'src/navigator/Headers' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import Colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' diff --git a/src/fiatconnect/RefetchQuoteScreen.tsx b/src/fiatconnect/RefetchQuoteScreen.tsx index ca629af2389..d3d808f5811 100644 --- a/src/fiatconnect/RefetchQuoteScreen.tsx +++ b/src/fiatconnect/RefetchQuoteScreen.tsx @@ -1,7 +1,6 @@ import { NativeStackScreenProps } from '@react-navigation/native-stack' import React, { useEffect } from 'react' import { ActivityIndicator, StyleSheet, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import { cachedQuoteParamsSelector, fiatConnectQuotesErrorSelector, @@ -10,6 +9,7 @@ import { refetchQuote } from 'src/fiatconnect/slice' import { navigateHome } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import variables from 'src/styles/variables' import { useTokenInfoWithAddressBySymbol } from 'src/tokens/hooks' diff --git a/src/fiatconnect/ReviewScreen.tsx b/src/fiatconnect/ReviewScreen.tsx index 4a4bdae000d..06036cba263 100644 --- a/src/fiatconnect/ReviewScreen.tsx +++ b/src/fiatconnect/ReviewScreen.tsx @@ -5,7 +5,6 @@ import BigNumber from 'bignumber.js' import React, { useEffect, useLayoutEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, BackHandler, SafeAreaView, StyleSheet, Text, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import BackButton from 'src/components/BackButton' @@ -35,6 +34,7 @@ import { emptyHeader } from 'src/navigator/Headers' import { navigate, navigateBack, navigateHome } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' diff --git a/src/fiatconnect/TransferStatusScreen.tsx b/src/fiatconnect/TransferStatusScreen.tsx index c698abf7722..9399d9ff1a8 100644 --- a/src/fiatconnect/TransferStatusScreen.tsx +++ b/src/fiatconnect/TransferStatusScreen.tsx @@ -2,7 +2,6 @@ import { NativeStackScreenProps } from '@react-navigation/native-stack' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, SafeAreaView, StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import BackButton from 'src/components/BackButton' @@ -23,6 +22,7 @@ import { emptyHeader } from 'src/navigator/Headers' import { navigate, navigateHome } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useSelector } from 'src/redux/hooks' import appTheme from 'src/styles/appTheme' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' diff --git a/src/fiatconnect/kyc/KycDenied.tsx b/src/fiatconnect/kyc/KycDenied.tsx index 0b3965fd83f..a3f86774d34 100644 --- a/src/fiatconnect/kyc/KycDenied.tsx +++ b/src/fiatconnect/kyc/KycDenied.tsx @@ -4,7 +4,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' @@ -14,6 +13,7 @@ import { kycTryAgain } from 'src/fiatconnect/slice' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' diff --git a/src/fiatconnect/kyc/KycExpired.tsx b/src/fiatconnect/kyc/KycExpired.tsx index d2a81e5ce45..71f91517abd 100644 --- a/src/fiatconnect/kyc/KycExpired.tsx +++ b/src/fiatconnect/kyc/KycExpired.tsx @@ -4,7 +4,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { FiatExchangeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' @@ -14,6 +13,7 @@ import { kycTryAgain } from 'src/fiatconnect/slice' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' diff --git a/src/home/ActionsCarousel.tsx b/src/home/ActionsCarousel.tsx index 4fed223f60c..cab56d78abd 100644 --- a/src/home/ActionsCarousel.tsx +++ b/src/home/ActionsCarousel.tsx @@ -1,7 +1,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text } from 'react-native' -import { useSelector } from 'react-redux' import { HomeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Card from 'src/components/Card' @@ -16,6 +15,7 @@ import QuickActionsWithdraw from 'src/icons/quick-actions/Withdraw' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { isAppSwapsEnabledSelector } from 'src/navigator/selectors' +import { useSelector } from 'src/redux/hooks' import Colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' diff --git a/src/home/CashInBottomSheet.tsx b/src/home/CashInBottomSheet.tsx index 8b0718d896d..05cbbf58487 100644 --- a/src/home/CashInBottomSheet.tsx +++ b/src/home/CashInBottomSheet.tsx @@ -16,7 +16,7 @@ import { getLocalCurrencyCode } from 'src/localCurrency/selectors' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { userLocationDataSelector } from 'src/networkInfo/selectors' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' diff --git a/src/home/DappsCarousel.tsx b/src/home/DappsCarousel.tsx index 10f689fec43..8b054fb5a8d 100644 --- a/src/home/DappsCarousel.tsx +++ b/src/home/DappsCarousel.tsx @@ -10,7 +10,6 @@ import { Text, View, } from 'react-native' -import { useSelector } from 'react-redux' import { DappExplorerEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Card from 'src/components/Card' @@ -24,6 +23,7 @@ import { ActiveDapp, DappSection } from 'src/dapps/types' import ArrowRight from 'src/icons/ArrowRight' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' +import { useSelector } from 'src/redux/hooks' import { Colors } from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/home/GetStarted.tsx b/src/home/GetStarted.tsx index bd70db4fdb7..8abeb091683 100644 --- a/src/home/GetStarted.tsx +++ b/src/home/GetStarted.tsx @@ -8,7 +8,7 @@ import { FiatExchangeFlow } from 'src/fiatExchanges/utils' import Bird from 'src/icons/Bird' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/home/NotificationBellSpotlight.tsx b/src/home/NotificationBellSpotlight.tsx index 92a2f510461..2f9eec21e0f 100644 --- a/src/home/NotificationBellSpotlight.tsx +++ b/src/home/NotificationBellSpotlight.tsx @@ -3,13 +3,13 @@ import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated' import { useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { HomeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { notificationSpotlightSeen } from 'src/app/actions' import Button, { BtnSizes } from 'src/components/Button' import { useShowOrHideAnimation } from 'src/components/useShowOrHideAnimation' import NotificationBell from 'src/home/NotificationBell' +import { useDispatch } from 'src/redux/hooks' import Colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/home/NotificationBox.tsx b/src/home/NotificationBox.tsx index 0f8d7564145..6d774781776 100644 --- a/src/home/NotificationBox.tsx +++ b/src/home/NotificationBox.tsx @@ -2,7 +2,6 @@ import * as React from 'react' import { useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { NativeScrollEvent, ScrollView, StyleSheet, View } from 'react-native' -import { useDispatch } from 'react-redux' import { dismissGetVerified, dismissGoldEducation, @@ -11,8 +10,8 @@ import { } from 'src/account/actions' import { celoEducationCompletedSelector } from 'src/account/selectors' import { HomeEvents, RewardsEvents } from 'src/analytics/Events' -import { ScrollDirection } from 'src/analytics/types' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' +import { ScrollDirection } from 'src/analytics/types' import { openUrl } from 'src/app/actions' import { numberVerifiedDecentrallySelector, @@ -36,12 +35,12 @@ import GuideKeyIcon from 'src/icons/GuideKeyHomeCardIcon' import { boostRewards, getVerified, learnCelo, lightningPhone } from 'src/images/Images' import { ensurePincode, navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import variables from 'src/styles/variables' -import { getContentForCurrentLang } from 'src/utils/contentTranslations' import Logger from 'src/utils/Logger' +import { getContentForCurrentLang } from 'src/utils/contentTranslations' const TAG = 'NotificationBox' // Priority of static notifications diff --git a/src/home/NotificationCenter.tsx b/src/home/NotificationCenter.tsx index 0330ffd45cc..882872005c0 100644 --- a/src/home/NotificationCenter.tsx +++ b/src/home/NotificationCenter.tsx @@ -5,7 +5,6 @@ import { useTranslation } from 'react-i18next' import { LayoutChangeEvent, StyleSheet, Text, View, ViewToken } from 'react-native' import Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated' import { useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { HomeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { openUrl } from 'src/app/actions' @@ -20,7 +19,7 @@ import ThumbsUpIllustration from 'src/icons/ThumbsUpIllustration' import { Screens } from 'src/navigator/Screens' import useScrollAwareHeader from 'src/navigator/ScrollAwareHeader' import { StackParamList } from 'src/navigator/types' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/home/SendBar.tsx b/src/home/SendBar.tsx index c2ee7c9233d..a32df603c2f 100644 --- a/src/home/SendBar.tsx +++ b/src/home/SendBar.tsx @@ -6,7 +6,7 @@ import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes } from 'src/components/Button' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { canSendTokensSelector } from 'src/send/selectors' import colors from 'src/styles/colors' import variables from 'src/styles/variables' diff --git a/src/home/WalletHome.tsx b/src/home/WalletHome.tsx index 642ad13640d..ef68e7688e8 100644 --- a/src/home/WalletHome.tsx +++ b/src/home/WalletHome.tsx @@ -5,7 +5,6 @@ import { useTranslation } from 'react-i18next' import { RefreshControl, RefreshControlProps, SectionList, StyleSheet, View } from 'react-native' import Animated from 'react-native-reanimated' import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { showMessage } from 'src/alert/actions' import { AppState } from 'src/app/actions' import { @@ -36,7 +35,7 @@ import { showNftCelebrationSelector } from 'src/home/selectors' import { importContacts } from 'src/identity/actions' import DrawerTopBar from 'src/navigator/DrawerTopBar' import { phoneRecipientCacheSelector } from 'src/recipients/reducer' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { initializeSentryUserContext } from 'src/sentry/actions' import { getExperimentParams, getFeatureGate } from 'src/statsig' import { ExperimentConfigs } from 'src/statsig/constants' diff --git a/src/home/celebration/NftCelebration.tsx b/src/home/celebration/NftCelebration.tsx index 18f498fdbc8..6acad8c9068 100644 --- a/src/home/celebration/NftCelebration.tsx +++ b/src/home/celebration/NftCelebration.tsx @@ -3,7 +3,6 @@ import React, { useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import { useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { HomeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { BottomSheetRefType } from 'src/components/BottomSheet' @@ -16,6 +15,7 @@ import ImageErrorIcon from 'src/icons/ImageErrorIcon' import NftMedia from 'src/nfts/NftMedia' import { nftsWithMetadataSelector } from 'src/nfts/selectors' import { NftOrigin } from 'src/nfts/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import { Colors } from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { vibrateSuccess } from 'src/styles/hapticFeedback' diff --git a/src/home/useBalanceAutoRefresh.ts b/src/home/useBalanceAutoRefresh.ts index 61b4bd40a2e..b2fcc57a953 100644 --- a/src/home/useBalanceAutoRefresh.ts +++ b/src/home/useBalanceAutoRefresh.ts @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { useDispatch } from 'react-redux' import { startBalanceAutorefresh, stopBalanceAutorefresh } from 'src/home/actions' +import { useDispatch } from 'src/redux/hooks' export default function useBalanceAutoRefresh() { const dispatch = useDispatch() diff --git a/src/i18n/useChangeLanguage.ts b/src/i18n/useChangeLanguage.ts index da2f7fe0d9b..c6f0ad08381 100644 --- a/src/i18n/useChangeLanguage.ts +++ b/src/i18n/useChangeLanguage.ts @@ -1,6 +1,6 @@ -import { useDispatch } from 'react-redux' import i18n from 'src/i18n' import { setLanguage } from 'src/i18n/slice' +import { useDispatch } from 'src/redux/hooks' import Logger from 'src/utils/Logger' const TAG = 'i18n/actions' diff --git a/src/import/ImportWallet.tsx b/src/import/ImportWallet.tsx index 67ee54f22ff..26eb0d0bbc3 100644 --- a/src/import/ImportWallet.tsx +++ b/src/import/ImportWallet.tsx @@ -6,7 +6,6 @@ import React, { useEffect, useLayoutEffect, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { Keyboard, StyleSheet, Text, View } from 'react-native' import { SafeAreaInsetsContext } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { cancelCreateOrRestoreAccount } from 'src/account/actions' import { accountToRecoverSelector, recoveringFromStoreWipeSelector } from 'src/account/selectors' import { hideAlert } from 'src/alert/actions' @@ -30,8 +29,8 @@ import { navigate, navigateClearingStack } from 'src/navigator/NavigationService import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import TopBarTextButtonOnboarding from 'src/onboarding/TopBarTextButtonOnboarding' +import { useDispatch, useSelector } from 'src/redux/hooks' import { isAppConnected } from 'src/redux/selectors' -import useTypedSelector from 'src/redux/useSelector' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import colors from 'src/styles/colors' @@ -50,10 +49,10 @@ function ImportWallet({ navigation, route }: Props) { const [backupPhrase, setBackupPhrase] = useState('') const [keyboardVisible, setKeyboardVisible] = useState(false) - const isImportingWallet = useTypedSelector((state) => state.imports.isImportingWallet) + const isImportingWallet = useSelector((state) => state.imports.isImportingWallet) const appConnected = useSelector(isAppConnected) - const isRecoveringFromStoreWipe = useTypedSelector(recoveringFromStoreWipeSelector) - const accountToRecoverFromStoreWipe = useTypedSelector(accountToRecoverSelector) + const isRecoveringFromStoreWipe = useSelector(recoveringFromStoreWipeSelector) + const accountToRecoverFromStoreWipe = useSelector(accountToRecoverSelector) const dispatch = useDispatch() const { t } = useTranslation() diff --git a/src/invite/Invite.tsx b/src/invite/Invite.tsx index c90be5ae9e9..e112347f84e 100644 --- a/src/invite/Invite.tsx +++ b/src/invite/Invite.tsx @@ -2,17 +2,17 @@ import { isNil } from 'lodash' import React from 'react' import { useTranslation } from 'react-i18next' import { Share } from 'react-native' -import { useSelector } from 'react-redux' import { InviteEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { INVITE_REWARDS_NFTS_LEARN_MORE, INVITE_REWARDS_STABLETOKEN_LEARN_MORE } from 'src/config' import { inviteModal, inviteWithRewards } from 'src/images/Images' import { noHeader } from 'src/navigator/Headers' import { navigateBack } from 'src/navigator/NavigationService' +import { useSelector } from 'src/redux/hooks' import { inviteRewardsActiveSelector, inviteRewardsTypeSelector } from 'src/send/selectors' import { InviteRewardsType } from 'src/send/types' -import { useShareUrl } from './hooks' import InviteModal from './InviteModal' +import { useShareUrl } from './hooks' export default function Invite() { const { t } = useTranslation() diff --git a/src/invite/hooks.tsx b/src/invite/hooks.tsx index 5b4ed6d7c7c..2a3bf47d83b 100644 --- a/src/invite/hooks.tsx +++ b/src/invite/hooks.tsx @@ -2,9 +2,9 @@ import { isNil } from 'lodash' import { useState } from 'react' import { useAsync } from 'react-async-hook' import { useTranslation } from 'react-i18next' -import { useDispatch, useSelector } from 'react-redux' import { showError } from 'src/alert/actions' import { FIREBASE_ENABLED } from 'src/config' +import { useDispatch, useSelector } from 'src/redux/hooks' import Logger from 'src/utils/Logger' import { walletAddressSelector } from 'src/web3/selectors' import { createInviteLink } from '../firebase/dynamicLinks' diff --git a/src/jumpstart/JumpstartEnterAmount.tsx b/src/jumpstart/JumpstartEnterAmount.tsx index a51498dee4a..e9f51ee956a 100644 --- a/src/jumpstart/JumpstartEnterAmount.tsx +++ b/src/jumpstart/JumpstartEnterAmount.tsx @@ -9,7 +9,7 @@ import { createJumpstartLink } from 'src/firebase/dynamicLinks' import { usePrepareJumpstartTransactions } from 'src/jumpstart/usePrepareJumpstartTransactions' import { convertDollarsToLocalAmount } from 'src/localCurrency/convert' import { getLocalCurrencyCode, usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import EnterAmount from 'src/send/EnterAmount' import { getDynamicConfigParams } from 'src/statsig' import { DynamicConfigs } from 'src/statsig/constants' diff --git a/src/jumpstart/SelectJumpstartRecipientButton.tsx b/src/jumpstart/SelectJumpstartRecipientButton.tsx index 45edac0b5cd..c886a5fcda2 100644 --- a/src/jumpstart/SelectJumpstartRecipientButton.tsx +++ b/src/jumpstart/SelectJumpstartRecipientButton.tsx @@ -8,7 +8,7 @@ import CircledIcon from 'src/icons/CircledIcon' import MagicWand from 'src/icons/MagicWand' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import colors from 'src/styles/colors' diff --git a/src/keylessBackup/KeylessBackupPhoneInput.tsx b/src/keylessBackup/KeylessBackupPhoneInput.tsx index 992cefb1441..142cb194660 100644 --- a/src/keylessBackup/KeylessBackupPhoneInput.tsx +++ b/src/keylessBackup/KeylessBackupPhoneInput.tsx @@ -4,7 +4,6 @@ import React, { useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { SafeAreaView, ScrollView, StyleSheet, Text } from 'react-native' import * as RNLocalize from 'react-native-localize' -import { useSelector } from 'react-redux' import { defaultCountryCodeSelector, e164NumberSelector } from 'src/account/selectors' import { getPhoneNumberDetails } from 'src/account/utils' import { KeylessBackupEvents } from 'src/analytics/Events' @@ -18,6 +17,7 @@ import { emptyHeader } from 'src/navigator/Headers' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useSelector } from 'src/redux/hooks' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/keylessBackup/KeylessBackupProgress.tsx b/src/keylessBackup/KeylessBackupProgress.tsx index b1cb131d73c..19d3e8bd993 100644 --- a/src/keylessBackup/KeylessBackupProgress.tsx +++ b/src/keylessBackup/KeylessBackupProgress.tsx @@ -4,7 +4,6 @@ import React, { useEffect, useLayoutEffect } from 'react' import { Trans, useTranslation } from 'react-i18next' import { BackHandler, ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { KeylessBackupEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' @@ -24,6 +23,7 @@ import { TopBarTextButton } from 'src/navigator/TopBarButton' import { StackParamList } from 'src/navigator/types' import { goToNextOnboardingScreen, onboardingPropsSelector } from 'src/onboarding/steps' import { totalPositionsBalanceUsdSelector } from 'src/positions/selectors' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/keylessBackup/SignInWithEmail.tsx b/src/keylessBackup/SignInWithEmail.tsx index 16847b2aabc..210a70b0798 100644 --- a/src/keylessBackup/SignInWithEmail.tsx +++ b/src/keylessBackup/SignInWithEmail.tsx @@ -3,7 +3,6 @@ import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { SafeAreaView, ScrollView, StyleSheet, Text } from 'react-native' import { useAuth0 } from 'react-native-auth0' -import { useDispatch } from 'react-redux' import { KeylessBackupEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' @@ -15,6 +14,7 @@ import { emptyHeader } from 'src/navigator/Headers' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' +import { useDispatch } from 'src/redux/hooks' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/keylessBackup/hooks.ts b/src/keylessBackup/hooks.ts index d5d72aa9c35..ec45266af97 100644 --- a/src/keylessBackup/hooks.ts +++ b/src/keylessBackup/hooks.ts @@ -2,13 +2,13 @@ import { useRef, useState } from 'react' import { useAsync } from 'react-async-hook' import { Platform } from 'react-native' import DeviceInfo from 'react-native-device-info' -import { useDispatch } from 'react-redux' import { showError } from 'src/alert/actions' import { KeylessBackupEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { ErrorMessages } from 'src/app/ErrorMessages' import { valoraKeyshareIssued } from 'src/keylessBackup/slice' import { KeylessBackupFlow } from 'src/keylessBackup/types' +import { useDispatch } from 'src/redux/hooks' import Logger from 'src/utils/Logger' import { PhoneNumberVerificationStatus } from 'src/verify/hooks' import networkConfig from 'src/web3/networkConfig' diff --git a/src/localCurrency/SelectLocalCurrency.tsx b/src/localCurrency/SelectLocalCurrency.tsx index c235f53ce86..b7a95d6d974 100644 --- a/src/localCurrency/SelectLocalCurrency.tsx +++ b/src/localCurrency/SelectLocalCurrency.tsx @@ -2,14 +2,14 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { FlatList, ListRenderItemInfo, ScrollView, StyleSheet, Text } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import SelectionOption from 'src/components/SelectionOption' import i18n from 'src/i18n' import { selectPreferredCurrency } from 'src/localCurrency/actions' -import { LocalCurrencyCode, LOCAL_CURRENCY_CODES } from 'src/localCurrency/consts' +import { LOCAL_CURRENCY_CODES, LocalCurrencyCode } from 'src/localCurrency/consts' import { useLocalCurrencyCode } from 'src/localCurrency/hooks' import { headerWithBackButton } from 'src/navigator/Headers' import { navigateBack } from 'src/navigator/NavigationService' +import { useDispatch } from 'src/redux/hooks' import fontStyles from 'src/styles/fonts' const DEFAULT_CURRENCY_CODE = LocalCurrencyCode.USD diff --git a/src/localCurrency/hooks.ts b/src/localCurrency/hooks.ts index 31c91586d11..5ffa86ceea7 100644 --- a/src/localCurrency/hooks.ts +++ b/src/localCurrency/hooks.ts @@ -3,7 +3,7 @@ import { LocalCurrencyCode } from 'src/localCurrency/consts' import { convertDollarsToLocalAmount } from 'src/localCurrency/convert' import { getLocalCurrencyCode, usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' import { CurrencyInfo } from 'src/localCurrency/types' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { useTokenInfoWithAddressBySymbol } from 'src/tokens/hooks' import { convertTokenToLocalAmount } from 'src/tokens/utils' import { Currency } from 'src/utils/currencies' diff --git a/src/navigator/DrawerNavigator.tsx b/src/navigator/DrawerNavigator.tsx index ee6b7f6c632..2829c28608c 100644 --- a/src/navigator/DrawerNavigator.tsx +++ b/src/navigator/DrawerNavigator.tsx @@ -58,7 +58,7 @@ import RewardsPill from 'src/navigator/RewardsPill' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import NftGallery from 'src/nfts/NftGallery' -import { default as useSelector } from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' @@ -314,7 +314,6 @@ export default function DrawerNavigator({ route }: Props) { {showRecoveryPhrase && ( ( diff --git a/src/navigator/Navigator.tsx b/src/navigator/Navigator.tsx index 6c7de14c657..de0668dafc4 100644 --- a/src/navigator/Navigator.tsx +++ b/src/navigator/Navigator.tsx @@ -627,7 +627,6 @@ const modalAnimatedScreens = (Navigator: typeof Stack) => ( /> diff --git a/src/navigator/NavigatorWrapper.tsx b/src/navigator/NavigatorWrapper.tsx index 2959b59b363..3802e477aae 100644 --- a/src/navigator/NavigatorWrapper.tsx +++ b/src/navigator/NavigatorWrapper.tsx @@ -6,13 +6,12 @@ import { SeverityLevel } from '@sentry/types' import * as React from 'react' import { StyleSheet, View } from 'react-native' import DeviceInfo from 'react-native-device-info' -import { useDispatch } from 'react-redux' import ShakeForSupport from 'src/account/ShakeForSupport' import AlertBanner from 'src/alert/AlertBanner' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' +import UpgradeScreen from 'src/app/UpgradeScreen' import { activeScreenChanged } from 'src/app/actions' import { getAppLocked } from 'src/app/selectors' -import UpgradeScreen from 'src/app/UpgradeScreen' import { useDeepLinks } from 'src/app/useDeepLinks' import { DEV_RESTORE_NAV_STATE_ON_RELOAD } from 'src/config' import { @@ -24,11 +23,11 @@ import Navigator from 'src/navigator/Navigator' import { Screens } from 'src/navigator/Screens' import PincodeLock from 'src/pincode/PincodeLock' import HooksPreviewModeBanner from 'src/positions/HooksPreviewModeBanner' -import useTypedSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { sentryRoutingInstrumentation } from 'src/sentry/Sentry' import appTheme from 'src/styles/appTheme' -import { userInSanctionedCountrySelector } from 'src/utils/countryFeatures' import Logger from 'src/utils/Logger' +import { userInSanctionedCountrySelector } from 'src/utils/countryFeatures' import { isVersionBelowMinimum } from 'src/utils/versionCheck' // This uses RN Navigation's experimental nav state persistence @@ -53,10 +52,10 @@ const RESTORE_STATE = __DEV__ && DEV_RESTORE_NAV_STATE_ON_RELOAD export const NavigatorWrapper = () => { const [isReady, setIsReady] = React.useState(RESTORE_STATE ? false : true) const [initialState, setInitialState] = React.useState() - const appLocked = useTypedSelector(getAppLocked) - const minRequiredVersion = useTypedSelector((state) => state.app.minVersion) + const appLocked = useSelector(getAppLocked) + const minRequiredVersion = useSelector((state) => state.app.minVersion) const routeNameRef = React.useRef() - const inSanctionedCountry = useTypedSelector(userInSanctionedCountrySelector) + const inSanctionedCountry = useSelector(userInSanctionedCountrySelector) const dispatch = useDispatch() diff --git a/src/navigator/QRNavigator.tsx b/src/navigator/QRNavigator.tsx index 90c42d81f03..8088e9f4428 100644 --- a/src/navigator/QRNavigator.tsx +++ b/src/navigator/QRNavigator.tsx @@ -11,7 +11,6 @@ import { Dimensions, Platform, StatusBar, StyleSheet } from 'react-native' import { PERMISSIONS, RESULTS, check } from 'react-native-permissions' import Animated, { call, greaterThan, onChange } from 'react-native-reanimated' import { ScrollPager } from 'react-native-tab-view' -import { useDispatch } from 'react-redux' import { QrScreenEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { noHeader } from 'src/navigator/Headers' @@ -20,6 +19,7 @@ import { QRTabParamList, StackParamList } from 'src/navigator/types' import QRCode from 'src/qrcode/QRCode' import QRScanner from 'src/qrcode/QRScanner' import QRTabBar from 'src/qrcode/QRTabBar' +import { useDispatch } from 'src/redux/hooks' import { SVG, handleQRCodeDetected } from 'src/send/actions' import { QrCode } from 'src/send/types' import Logger from 'src/utils/Logger' diff --git a/src/navigator/RewardsPill.tsx b/src/navigator/RewardsPill.tsx index 08076c6b5a0..7d61c2ca67e 100644 --- a/src/navigator/RewardsPill.tsx +++ b/src/navigator/RewardsPill.tsx @@ -10,7 +10,7 @@ import { superchargeInfoSelector } from 'src/consumerIncentives/selectors' import Rings from 'src/icons/Rings' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' diff --git a/src/nfts/NftGallery.tsx b/src/nfts/NftGallery.tsx index 98491bf4048..1c8867f42ad 100644 --- a/src/nfts/NftGallery.tsx +++ b/src/nfts/NftGallery.tsx @@ -2,7 +2,6 @@ import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { FlatList, RefreshControl, StyleSheet, Text, View } from 'react-native' import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { NftEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Touchable from 'src/components/Touchable' @@ -20,6 +19,7 @@ import { } from 'src/nfts/selectors' import { fetchNfts } from 'src/nfts/slice' import { NftOrigin } from 'src/nfts/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/nfts/NftMedia.tsx b/src/nfts/NftMedia.tsx index 300612fae64..845d027e63e 100644 --- a/src/nfts/NftMedia.tsx +++ b/src/nfts/NftMedia.tsx @@ -3,12 +3,12 @@ import React, { useEffect, useState } from 'react' import { Platform, View } from 'react-native' import FastImage from 'react-native-fast-image' import Video, { ResizeMode } from 'react-native-video' -import { useSelector } from 'react-redux' import { NftEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import SkeletonPlaceholder from 'src/components/SkeletonPlaceholder' import { nftsLoadingSelector } from 'src/nfts/selectors' import { Nft, NftOrigin } from 'src/nfts/types' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import variables from 'src/styles/variables' import Logger from 'src/utils/Logger' diff --git a/src/onboarding/ChooseYourAdventure.tsx b/src/onboarding/ChooseYourAdventure.tsx index ef49fd65ea3..592496b1445 100644 --- a/src/onboarding/ChooseYourAdventure.tsx +++ b/src/onboarding/ChooseYourAdventure.tsx @@ -2,7 +2,6 @@ import React, { useMemo } from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useSelector } from 'react-redux' import { OnboardingEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Card from 'src/components/Card' @@ -18,6 +17,7 @@ import { nuxNavigationOptionsNoBackButton } from 'src/navigator/Headers' import { navigate, navigateHome } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { AdventureCardName } from 'src/onboarding/types' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Shadow, Spacing } from 'src/styles/styles' diff --git a/src/onboarding/registration/EnableBiometry.tsx b/src/onboarding/registration/EnableBiometry.tsx index e08771f98dc..64c02184136 100644 --- a/src/onboarding/registration/EnableBiometry.tsx +++ b/src/onboarding/registration/EnableBiometry.tsx @@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text, View } from 'react-native' import * as Keychain from 'react-native-keychain' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { setPincodeSuccess } from 'src/account/actions' import { PincodeType } from 'src/account/reducer' import { OnboardingEvents } from 'src/analytics/Events' @@ -26,7 +25,7 @@ import { onboardingPropsSelector, } from 'src/onboarding/steps' import { setPincodeWithBiometry } from 'src/pincode/authentication' -import useTypedSelector, { default as useSelector } from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { isUserCancelledError } from 'src/storage/keychain' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' @@ -52,7 +51,7 @@ export default function EnableBiometry({ navigation }: Props) { // This screen would not be displayed if supportedBiometryType were null const supportedBiometryType = useSelector(supportedBiometryTypeSelector) - const onboardingProps = useTypedSelector(onboardingPropsSelector) + const onboardingProps = useSelector(onboardingPropsSelector) const { step, totalSteps } = getOnboardingStepValues(Screens.EnableBiometry, onboardingProps) diff --git a/src/onboarding/registration/ImportSelect.tsx b/src/onboarding/registration/ImportSelect.tsx index 41dc46ad533..e4da9814129 100644 --- a/src/onboarding/registration/ImportSelect.tsx +++ b/src/onboarding/registration/ImportSelect.tsx @@ -4,7 +4,6 @@ import React, { useLayoutEffect } from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { cancelCreateOrRestoreAccount } from 'src/account/actions' import { OnboardingEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -18,6 +17,7 @@ import { navigate, navigateClearingStack } from 'src/navigator/NavigationService import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import TopBarTextButtonOnboarding from 'src/onboarding/TopBarTextButtonOnboarding' +import { useDispatch } from 'src/redux/hooks' import colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Shadow, Spacing } from 'src/styles/styles' diff --git a/src/onboarding/registration/NameAndPicture.tsx b/src/onboarding/registration/NameAndPicture.tsx index d4b694257c1..0e2509fd89d 100644 --- a/src/onboarding/registration/NameAndPicture.tsx +++ b/src/onboarding/registration/NameAndPicture.tsx @@ -3,7 +3,6 @@ import React, { useLayoutEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { setName } from 'src/account/actions' import { nameSelector } from 'src/account/selectors' import { hideAlert, showError } from 'src/alert/actions' @@ -23,16 +22,16 @@ import { goToNextOnboardingScreen, onboardingPropsSelector, } from 'src/onboarding/steps' -import { default as useTypedSelector } from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' type Props = NativeStackScreenProps function NameAndPicture({ navigation, route }: Props) { const [nameInput, setNameInput] = useState('') - const cachedName = useTypedSelector(nameSelector) - const choseToRestoreAccount = useTypedSelector((state) => state.account.choseToRestoreAccount) - const onboardingProps = useTypedSelector(onboardingPropsSelector) + const cachedName = useSelector(nameSelector) + const choseToRestoreAccount = useSelector((state) => state.account.choseToRestoreAccount) + const onboardingProps = useSelector(onboardingPropsSelector) const { step, totalSteps } = getOnboardingStepValues(Screens.NameAndPicture, onboardingProps) const dispatch = useDispatch() diff --git a/src/onboarding/registration/OnboardingRecoveryPhrase.tsx b/src/onboarding/registration/OnboardingRecoveryPhrase.tsx index a04e0f48e91..dd681c95f0c 100644 --- a/src/onboarding/registration/OnboardingRecoveryPhrase.tsx +++ b/src/onboarding/registration/OnboardingRecoveryPhrase.tsx @@ -4,7 +4,6 @@ import React, { useLayoutEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { recoveryPhraseInOnboardingCompleted } from 'src/account/actions' import { OnboardingEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -26,7 +25,7 @@ import { goToNextOnboardingScreen, onboardingPropsSelector, } from 'src/onboarding/steps' -import { default as useTypedSelector } from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import Logger from 'src/utils/Logger' @@ -34,7 +33,7 @@ import Logger from 'src/utils/Logger' type Props = NativeStackScreenProps function OnboardingRecoveryPhrase({ navigation }: Props) { - const onboardingProps = useTypedSelector(onboardingPropsSelector) + const onboardingProps = useSelector(onboardingPropsSelector) const { step, totalSteps } = getOnboardingStepValues(Screens.ProtectWallet, onboardingProps) const accountKey = useAccountKey() const [showBottomSheet, setShowBottomSheet] = useState(false) diff --git a/src/onboarding/registration/PictureInput.tsx b/src/onboarding/registration/PictureInput.tsx index 86b4c7ce3ce..22a630aedfb 100644 --- a/src/onboarding/registration/PictureInput.tsx +++ b/src/onboarding/registration/PictureInput.tsx @@ -2,13 +2,13 @@ import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { Platform, StyleSheet, View } from 'react-native' import ImagePicker from 'react-native-image-crop-picker' -import { useSelector } from 'react-redux' import { currentUserRecipientSelector } from 'src/account/selectors' import ContactCircle from 'src/components/ContactCircle' import OptionsChooser from 'src/components/OptionsChooser' import Touchable from 'src/components/Touchable' import Edit from 'src/icons/Edit' import { Recipient } from 'src/recipients/recipient' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import Logger from 'src/utils/Logger' import { ensureError } from 'src/utils/ensureError' diff --git a/src/onboarding/registration/ProtectWallet.tsx b/src/onboarding/registration/ProtectWallet.tsx index d4effd7adbb..aa8be77b26c 100644 --- a/src/onboarding/registration/ProtectWallet.tsx +++ b/src/onboarding/registration/ProtectWallet.tsx @@ -3,7 +3,6 @@ import React, { useEffect, useLayoutEffect } from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { recoveryPhraseInOnboardingStarted } from 'src/account/actions' import { RecoveryPhraseInOnboardingStatus } from 'src/account/reducer' import { recoveryPhraseInOnboardingStatusSelector } from 'src/account/selectors' @@ -16,7 +15,7 @@ import { ensurePincode, navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { getOnboardingStepValues, onboardingPropsSelector } from 'src/onboarding/steps' -import { default as useTypedSelector } from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import variables from 'src/styles/variables' @@ -28,7 +27,7 @@ const TAG = 'ProtectWallet' type Props = NativeStackScreenProps function ProtectWallet({ navigation }: Props) { - const onboardingProps = useTypedSelector(onboardingPropsSelector) + const onboardingProps = useSelector(onboardingPropsSelector) const { step, totalSteps } = getOnboardingStepValues(Screens.ProtectWallet, onboardingProps) const address = useSelector(walletAddressSelector) const { t } = useTranslation() diff --git a/src/onboarding/success/OnboardingSuccessScreen.tsx b/src/onboarding/success/OnboardingSuccessScreen.tsx index 4c9075546b4..28bd72e1f92 100644 --- a/src/onboarding/success/OnboardingSuccessScreen.tsx +++ b/src/onboarding/success/OnboardingSuccessScreen.tsx @@ -6,13 +6,13 @@ import { background } from 'src/images/Images' import { nuxNavigationOptionsNoBackButton } from 'src/navigator/Headers' import { Screens } from 'src/navigator/Screens' import { goToNextOnboardingScreen, onboardingPropsSelector } from 'src/onboarding/steps' -import useTypedSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' function OnboardingSuccessScreen() { - const onboardingProps = useTypedSelector(onboardingPropsSelector) + const onboardingProps = useSelector(onboardingPropsSelector) useEffect(() => { const timeout = setTimeout( () => diff --git a/src/onboarding/welcome/Welcome.tsx b/src/onboarding/welcome/Welcome.tsx index a9bfce881df..a19ca72d40f 100644 --- a/src/onboarding/welcome/Welcome.tsx +++ b/src/onboarding/welcome/Welcome.tsx @@ -2,7 +2,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { Image, ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { chooseCreateAccount, chooseRestoreAccount } from 'src/account/actions' import { recoveringFromStoreWipeSelector } from 'src/account/selectors' import { OnboardingEvents } from 'src/analytics/Events' @@ -15,7 +14,7 @@ import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import LanguageButton from 'src/onboarding/LanguageButton' import { firstOnboardingScreen } from 'src/onboarding/steps' -import { default as useSelector } from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { getExperimentParams, patchUpdateStatsigUser } from 'src/statsig' import { ExperimentConfigs } from 'src/statsig/constants' import { StatsigExperiments } from 'src/statsig/types' diff --git a/src/pincode/PincodeEnter.tsx b/src/pincode/PincodeEnter.tsx index bbe1994e79d..67e4818212b 100644 --- a/src/pincode/PincodeEnter.tsx +++ b/src/pincode/PincodeEnter.tsx @@ -15,7 +15,7 @@ import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { checkPin } from 'src/pincode/authentication' import Pincode from 'src/pincode/Pincode' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { SentryTransactionHub } from 'src/sentry/SentryTransactionHub' import { SentryTransaction } from 'src/sentry/SentryTransactions' import { currentAccountSelector } from 'src/web3/selectors' diff --git a/src/pincode/PincodeLock.tsx b/src/pincode/PincodeLock.tsx index 209a3a3a971..339c96073a1 100644 --- a/src/pincode/PincodeLock.tsx +++ b/src/pincode/PincodeLock.tsx @@ -8,15 +8,15 @@ import { useTranslation } from 'react-i18next' import { BackHandler, Image, StyleSheet } from 'react-native' import RNExitApp from 'react-native-exit-app' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { PincodeType } from 'src/account/reducer' import { pincodeTypeSelector } from 'src/account/selectors' -import { appUnlock } from 'src/app/actions' import { ErrorMessages } from 'src/app/ErrorMessages' +import { appUnlock } from 'src/app/actions' import { supportedBiometryTypeSelector } from 'src/app/selectors' import { background } from 'src/images/Images' -import { checkPin, getPincodeWithBiometry } from 'src/pincode/authentication' import Pincode from 'src/pincode/Pincode' +import { checkPin, getPincodeWithBiometry } from 'src/pincode/authentication' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import { currentAccountSelector } from 'src/web3/selectors' diff --git a/src/positions/HooksPreviewModeBanner.tsx b/src/positions/HooksPreviewModeBanner.tsx index 13322f2a3ef..0e14b9631db 100644 --- a/src/positions/HooksPreviewModeBanner.tsx +++ b/src/positions/HooksPreviewModeBanner.tsx @@ -3,12 +3,12 @@ import { useTranslation } from 'react-i18next' import { StyleSheet, Text } from 'react-native' import Animated, { SlideInUp, SlideOutUp } from 'react-native-reanimated' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { BuilderHooksEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Touchable from 'src/components/Touchable' import { hooksPreviewApiUrlSelector, hooksPreviewStatusSelector } from 'src/positions/selectors' import { previewModeDisabled } from 'src/positions/slice' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fonts from 'src/styles/fonts' diff --git a/src/priceHistory/PriceHistoryChart.tsx b/src/priceHistory/PriceHistoryChart.tsx index 085b257944f..1e0a619e24a 100644 --- a/src/priceHistory/PriceHistoryChart.tsx +++ b/src/priceHistory/PriceHistoryChart.tsx @@ -10,15 +10,14 @@ import { ViewStyle, } from 'react-native' import { Circle, G, Line, Text as SvgText } from 'react-native-svg' -import { useDispatch } from 'react-redux' import i18n from 'src/i18n' import { LocalCurrencyCode } from 'src/localCurrency/consts' import { convertDollarsToLocalAmount } from 'src/localCurrency/convert' import { getLocalCurrencyCode, usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' import { priceHistoryPricesSelector, priceHistoryStatusSelector } from 'src/priceHistory/selectors' import { Price, fetchPriceHistoryStart } from 'src/priceHistory/slice' +import { useDispatch, useSelector } from 'src/redux/hooks' import { RootState } from 'src/redux/reducers' -import useSelector from 'src/redux/useSelector' import colors from 'src/styles/colors' import { Spacing } from 'src/styles/styles' import variables from 'src/styles/variables' diff --git a/src/qrcode/QRCode.tsx b/src/qrcode/QRCode.tsx index 070a3193ed5..a23e2f528dc 100644 --- a/src/qrcode/QRCode.tsx +++ b/src/qrcode/QRCode.tsx @@ -2,7 +2,6 @@ import Clipboard from '@react-native-clipboard/clipboard' import React, { useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import { nameSelector } from 'src/account/selectors' import Button from 'src/components/Button' import ExchangesBottomSheet from 'src/components/ExchangesBottomSheet' @@ -10,6 +9,7 @@ import InLineNotification, { Severity } from 'src/components/InLineNotification' import { ExternalExchangeProvider } from 'src/fiatExchanges/ExternalExchanges' import CopyIcon from 'src/icons/CopyIcon' import StyledQRCode from 'src/qrcode/StyledQRCode' +import { useSelector } from 'src/redux/hooks' import { SVG } from 'src/send/actions' import { NETWORK_NAMES } from 'src/shared/conts' import { getDynamicConfigParams } from 'src/statsig' diff --git a/src/qrcode/QRTabBar.tsx b/src/qrcode/QRTabBar.tsx index 12fcc6d140a..b3078871628 100644 --- a/src/qrcode/QRTabBar.tsx +++ b/src/qrcode/QRTabBar.tsx @@ -4,12 +4,12 @@ import { useTranslation } from 'react-i18next' import { Dimensions, Platform, StyleSheet, Text, View } from 'react-native' import Animated from 'react-native-reanimated' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import SegmentedControl from 'src/components/SegmentedControl' import BackChevron from 'src/icons/BackChevron' import Share from 'src/icons/Share' import Times from 'src/icons/Times' import { TopBarIconButton } from 'src/navigator/TopBarButton' +import { useDispatch } from 'src/redux/hooks' import { SVG, shareQRCode } from 'src/send/actions' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' diff --git a/src/recipients/RecipientItemV2.tsx b/src/recipients/RecipientItemV2.tsx index 6df4c986abc..b2a5b34aacb 100644 --- a/src/recipients/RecipientItemV2.tsx +++ b/src/recipients/RecipientItemV2.tsx @@ -6,8 +6,8 @@ import Touchable from 'src/components/Touchable' import Logo, { LogoTypes } from 'src/icons/Logo' import QuestionIcon from 'src/icons/QuestionIcon' import { - e164NumberToAddressSelector, addressToVerificationStatusSelector, + e164NumberToAddressSelector, } from 'src/identity/selectors' import { Recipient, @@ -15,7 +15,7 @@ import { getDisplayDetail, getDisplayName, } from 'src/recipients/recipient' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors, { Colors } from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/redux/hooks.ts b/src/redux/hooks.ts new file mode 100644 index 00000000000..cdc6131ddc3 --- /dev/null +++ b/src/redux/hooks.ts @@ -0,0 +1,5 @@ +import * as ReactRedux from 'react-redux' +import type { AppDispatch, RootState } from 'src/redux/store' + +export const useDispatch = ReactRedux.useDispatch.withTypes() +export const useSelector = ReactRedux.useSelector.withTypes() diff --git a/src/redux/store.ts b/src/redux/store.ts index 800a8a5d3c8..aacbe45bf78 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -8,7 +8,7 @@ import { PerformanceEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { createMigrate } from 'src/redux/createMigrate' import { migrations } from 'src/redux/migrations' -import rootReducer, { RootState } from 'src/redux/reducers' +import rootReducer, { RootState as ReducersRootState } from 'src/redux/reducers' import { rootSaga } from 'src/redux/sagas' import { resetStateOnInvalidStoredAccount } from 'src/utils/accountChecker' import Logger from 'src/utils/Logger' @@ -17,7 +17,7 @@ import { ONE_DAY_IN_MILLIS } from 'src/utils/time' const timeBetweenStoreSizeEvents = ONE_DAY_IN_MILLIS let lastEventTime = Date.now() -const persistConfig: PersistConfig = { +const persistConfig: PersistConfig = { key: 'root', // default is -1, increment as we make migrations // See https://github.com/valora-inc/wallet/tree/main/WALLET.md#redux-state-migration @@ -90,7 +90,7 @@ export const _persistConfig = persistConfig // eslint-disable-next-line no-var declare var window: any -export const setupStore = (initialState?: RootState, config = persistConfig) => { +export const setupStore = (initialState?: ReducersRootState, config = persistConfig) => { const sagaMiddleware = createSagaMiddleware({ onError: (error, errorInfo) => { // Log the uncaught error so it's captured by Sentry @@ -168,3 +168,6 @@ export const setupStore = (initialState?: RootState, config = persistConfig) => const { store, persistor } = setupStore() export { persistor, store } + +export type RootState = ReturnType +export type AppDispatch = typeof store.dispatch diff --git a/src/redux/useSelector.ts b/src/redux/useSelector.ts deleted file mode 100644 index f5019969bea..00000000000 --- a/src/redux/useSelector.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TypedUseSelectorHook, useSelector } from 'react-redux' -import { RootState } from 'src/redux/reducers' - -// useSelector hook that is properly typed for our store's root state -const useTypedSelector: TypedUseSelectorHook = useSelector - -export default useTypedSelector diff --git a/src/send/EnterAmount.tsx b/src/send/EnterAmount.tsx index 975390153cd..8ff1f5e0411 100644 --- a/src/send/EnterAmount.tsx +++ b/src/send/EnterAmount.tsx @@ -25,7 +25,7 @@ import TokenIcon, { IconSize } from 'src/components/TokenIcon' import Touchable from 'src/components/Touchable' import CustomHeader from 'src/components/header/CustomHeader' import DownArrowIcon from 'src/icons/DownArrowIcon' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' diff --git a/src/send/InviteRewardsCard.tsx b/src/send/InviteRewardsCard.tsx index 6bafd8136e0..1d2fc203e8f 100644 --- a/src/send/InviteRewardsCard.tsx +++ b/src/send/InviteRewardsCard.tsx @@ -1,8 +1,8 @@ import React from 'react' import { Trans, useTranslation } from 'react-i18next' import { Image, StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import { notificationInvite } from 'src/images/Images' +import { useSelector } from 'src/redux/hooks' import { inviteRewardsTypeSelector } from 'src/send/selectors' import { InviteRewardsType } from 'src/send/types' import Colors from 'src/styles/colors' diff --git a/src/send/SelectRecipientButtons.tsx b/src/send/SelectRecipientButtons.tsx index fc759c48523..2bf58c38118 100644 --- a/src/send/SelectRecipientButtons.tsx +++ b/src/send/SelectRecipientButtons.tsx @@ -18,7 +18,7 @@ import Social from 'src/icons/Social' import SelectRecipientJumpstartButton from 'src/jumpstart/SelectJumpstartRecipientButton' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import Logger from 'src/utils/Logger' import { CONTACTS_PERMISSION } from 'src/utils/contacts' import { navigateToPhoneSettings } from 'src/utils/linking' diff --git a/src/send/SendConfirmation.tsx b/src/send/SendConfirmation.tsx index 48361012b5a..67f0528f629 100644 --- a/src/send/SendConfirmation.tsx +++ b/src/send/SendConfirmation.tsx @@ -3,7 +3,6 @@ import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { Platform, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { showError } from 'src/alert/actions' import { SendEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -29,7 +28,7 @@ import { noHeader } from 'src/navigator/Headers' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { getDisplayName } from 'src/recipients/recipient' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { encryptComment, sendPayment } from 'src/send/actions' import { encryptedCommentSelector, diff --git a/src/send/SendEnterAmount.tsx b/src/send/SendEnterAmount.tsx index 02dfd262cd4..187b52707c4 100644 --- a/src/send/SendEnterAmount.tsx +++ b/src/send/SendEnterAmount.tsx @@ -7,7 +7,7 @@ import { getLocalCurrencyCode, usdToLocalCurrencyRateSelector } from 'src/localC import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import EnterAmount from 'src/send/EnterAmount' import { lastUsedTokenIdSelector } from 'src/send/selectors' import { usePrepareSendTransactions } from 'src/send/usePrepareSendTransactions' diff --git a/src/send/SendSelectRecipient.tsx b/src/send/SendSelectRecipient.tsx index e41368276ec..60ed7398f98 100644 --- a/src/send/SendSelectRecipient.tsx +++ b/src/send/SendSelectRecipient.tsx @@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next' import { Platform, StyleSheet, Text, View } from 'react-native' import { getFontScaleSync } from 'react-native-device-info' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { isAddressFormat } from 'src/account/utils' import { SendEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -31,7 +30,7 @@ import { TopBarIconButton } from 'src/navigator/TopBarButton' import { StackParamList } from 'src/navigator/types' import RecipientPicker from 'src/recipients/RecipientPickerV2' import { Recipient, RecipientType, recipientHasNumber } from 'src/recipients/recipient' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import InviteRewardsCard from 'src/send/InviteRewardsCard' import PasteAddressButton from 'src/send/PasteAddressButton' import SelectRecipientButtons from 'src/send/SelectRecipientButtons' diff --git a/src/send/ValidateRecipientIntro.tsx b/src/send/ValidateRecipientIntro.tsx index fb1c79ae777..ea3d972bb80 100644 --- a/src/send/ValidateRecipientIntro.tsx +++ b/src/send/ValidateRecipientIntro.tsx @@ -3,7 +3,6 @@ import * as React from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { SendEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import CancelButton from 'src/components/CancelButton' @@ -14,6 +13,7 @@ import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { getDisplayName } from 'src/recipients/recipient' +import { useDispatch } from 'src/redux/hooks' import { handleQRCodeDetectedSecureSend } from 'src/send/actions' import { QrCode } from 'src/send/types' import fontStyles from 'src/styles/fonts' diff --git a/src/send/hooks.ts b/src/send/hooks.ts index 4d8b239470a..ccece3d35bf 100644 --- a/src/send/hooks.ts +++ b/src/send/hooks.ts @@ -16,7 +16,7 @@ import { } from 'src/recipients/recipient' import { phoneRecipientCacheSelector, recipientInfoSelector } from 'src/recipients/reducer' import { resolveId } from 'src/recipients/resolve-id' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' const TYPING_DEBOUNCE_MILLSECONDS = 300 const SEARCH_THROTTLE_TIME = 100 diff --git a/src/send/useFetchRecipientVerificationStatus.ts b/src/send/useFetchRecipientVerificationStatus.ts index e8dfeccf7cc..acd221ec929 100644 --- a/src/send/useFetchRecipientVerificationStatus.ts +++ b/src/send/useFetchRecipientVerificationStatus.ts @@ -1,5 +1,4 @@ import { useEffect, useState } from 'react' -import { useDispatch } from 'react-redux' import { phoneNumberVerifiedSelector } from 'src/app/selectors' import { fetchAddressVerification, fetchAddressesAndValidate } from 'src/identity/actions' import { @@ -8,7 +7,7 @@ import { } from 'src/identity/selectors' import { RecipientVerificationStatus } from 'src/identity/types' import { Recipient, RecipientType, getRecipientVerificationStatus } from 'src/recipients/recipient' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' const useFetchRecipientVerificationStatus = () => { const [recipient, setRecipient] = useState(null) diff --git a/src/swap/SwapScreen.tsx b/src/swap/SwapScreen.tsx index eb16536201e..616ae0a6d99 100644 --- a/src/swap/SwapScreen.tsx +++ b/src/swap/SwapScreen.tsx @@ -8,7 +8,6 @@ import { StyleSheet, Text, View } from 'react-native' import { ScrollView } from 'react-native-gesture-handler' import { getNumberFormatSettings } from 'react-native-localize' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { showError } from 'src/alert/actions' import { SwapEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -30,7 +29,7 @@ import { getLocalCurrencyCode } from 'src/localCurrency/selectors' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' import { getDynamicConfigParams, getExperimentParams } from 'src/statsig' import { DynamicConfigs, ExperimentConfigs } from 'src/statsig/constants' diff --git a/src/swap/useFilterChips.ts b/src/swap/useFilterChips.ts index a2f3b279873..1f610e6313b 100644 --- a/src/swap/useFilterChips.ts +++ b/src/swap/useFilterChips.ts @@ -1,7 +1,7 @@ import { useTranslation } from 'react-i18next' import { FilterChip } from 'src/components/FilterChipsCarousel' import { TOKEN_MIN_AMOUNT } from 'src/config' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' import { getDynamicConfigParams, getFeatureGate } from 'src/statsig' import { DynamicConfigs } from 'src/statsig/constants' diff --git a/src/swap/useSwapQuote.ts b/src/swap/useSwapQuote.ts index 71e170f0e7f..a9bab2934b8 100644 --- a/src/swap/useSwapQuote.ts +++ b/src/swap/useSwapQuote.ts @@ -1,7 +1,7 @@ import BigNumber from 'bignumber.js' import { useAsyncCallback } from 'react-async-hook' import erc20 from 'src/abis/IERC20' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { FetchQuoteResponse, Field, ParsedSwapAmount, SwapTransaction } from 'src/swap/types' import { feeCurrenciesSelector } from 'src/tokens/selectors' import { TokenBalance } from 'src/tokens/slice' diff --git a/src/tokens/Assets.tsx b/src/tokens/Assets.tsx index 6d4b54e9a25..db5ac6298d5 100644 --- a/src/tokens/Assets.tsx +++ b/src/tokens/Assets.tsx @@ -18,7 +18,6 @@ import Animated, { useSharedValue, } from 'react-native-reanimated' import { useSafeAreaInsets } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import { AssetsEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' @@ -48,7 +47,7 @@ import { totalPositionsBalanceUsdSelector, } from 'src/positions/selectors' import { Position } from 'src/positions/types' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import Colors from 'src/styles/colors' diff --git a/src/tokens/TokenBalances.tsx b/src/tokens/TokenBalances.tsx index 6d4fdd0ea8c..5d6cabbb363 100644 --- a/src/tokens/TokenBalances.tsx +++ b/src/tokens/TokenBalances.tsx @@ -19,7 +19,6 @@ import Animated, { useSharedValue, } from 'react-native-reanimated' import { useSafeAreaInsets } from 'react-native-safe-area-context' -import { useSelector } from 'react-redux' import { AssetsEvents, HomeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' @@ -39,6 +38,7 @@ import { totalPositionsBalanceUsdSelector, } from 'src/positions/selectors' import { Position } from 'src/positions/types' +import { useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import Colors from 'src/styles/colors' diff --git a/src/tokens/TokenDetails.tsx b/src/tokens/TokenDetails.tsx index e7f02874b5d..187581aebaa 100644 --- a/src/tokens/TokenDetails.tsx +++ b/src/tokens/TokenDetails.tsx @@ -3,7 +3,6 @@ import React, { useRef } from 'react' import { useTranslation } from 'react-i18next' import { ScrollView, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useSelector } from 'react-redux' import { AssetsEvents } from 'src/analytics/Events' import { TokenProperties } from 'src/analytics/Properties' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' @@ -32,6 +31,7 @@ import { Screens } from 'src/navigator/Screens' import { isAppSwapsEnabledSelector } from 'src/navigator/selectors' import { StackParamList } from 'src/navigator/types' import PriceHistoryChart from 'src/priceHistory/PriceHistoryChart' +import { useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' diff --git a/src/tokens/TokenImport.tsx b/src/tokens/TokenImport.tsx index 1d0b753288a..108050a7d8e 100644 --- a/src/tokens/TokenImport.tsx +++ b/src/tokens/TokenImport.tsx @@ -4,7 +4,6 @@ import { useAsyncCallback } from 'react-async-hook' import { useTranslation } from 'react-i18next' import { Keyboard, StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch } from 'react-redux' import erc20 from 'src/abis/IERC20' import { showMessage } from 'src/alert/actions' import { AssetsEvents } from 'src/analytics/Events' @@ -22,7 +21,7 @@ import { noHeader } from 'src/navigator/Headers' import { navigateBack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' -import useSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' import { Colors } from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' diff --git a/src/tokens/hooks.ts b/src/tokens/hooks.ts index b3c4fc1fd05..a29368826fe 100644 --- a/src/tokens/hooks.ts +++ b/src/tokens/hooks.ts @@ -1,7 +1,7 @@ import BigNumber from 'bignumber.js' import { TIME_UNTIL_TOKEN_INFO_BECOMES_STALE } from 'src/config' import { usdToLocalCurrencyRateSelector } from 'src/localCurrency/selectors' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { getDynamicConfigParams, getFeatureGate } from 'src/statsig' import { DynamicConfigs } from 'src/statsig/constants' import { StatsigDynamicConfigs, StatsigFeatureGates } from 'src/statsig/types' diff --git a/src/transactions/CommentSection.tsx b/src/transactions/CommentSection.tsx index 090b5edc25b..5af4ccdf7ac 100644 --- a/src/transactions/CommentSection.tsx +++ b/src/transactions/CommentSection.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import HorizontalLine from 'src/components/HorizontalLine' import { decryptComment } from 'src/identity/commentEncryption' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { dataEncryptionKeySelector } from 'src/web3/selectors' diff --git a/src/transactions/feed/NftFeedItem.tsx b/src/transactions/feed/NftFeedItem.tsx index ca003d65fd7..c3de03ca9b8 100644 --- a/src/transactions/feed/NftFeedItem.tsx +++ b/src/transactions/feed/NftFeedItem.tsx @@ -11,7 +11,7 @@ import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import NftMedia from 'src/nfts/NftMedia' import { Nft, NftOrigin } from 'src/nfts/types' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import colors from 'src/styles/colors' diff --git a/src/transactions/feed/SwapFeedItem.tsx b/src/transactions/feed/SwapFeedItem.tsx index 79862bed9cd..f86f6415760 100644 --- a/src/transactions/feed/SwapFeedItem.tsx +++ b/src/transactions/feed/SwapFeedItem.tsx @@ -1,7 +1,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import { HomeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { hideHomeBalancesSelector } from 'src/app/selectors' @@ -9,6 +8,7 @@ import TokenDisplay from 'src/components/TokenDisplay' import Touchable from 'src/components/Touchable' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' +import { useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import colors from 'src/styles/colors' diff --git a/src/transactions/feed/TransactionDetailsScreen.tsx b/src/transactions/feed/TransactionDetailsScreen.tsx index b8f83c6f934..69fc7b0c116 100644 --- a/src/transactions/feed/TransactionDetailsScreen.tsx +++ b/src/transactions/feed/TransactionDetailsScreen.tsx @@ -14,7 +14,7 @@ import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { coinbasePaySendersSelector, rewardsSendersSelector } from 'src/recipients/reducer' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/transactions/feed/TransactionFeed.tsx b/src/transactions/feed/TransactionFeed.tsx index 13409408850..eb2f47f8a7f 100644 --- a/src/transactions/feed/TransactionFeed.tsx +++ b/src/transactions/feed/TransactionFeed.tsx @@ -2,7 +2,7 @@ import React, { useMemo } from 'react' import { ActivityIndicator, SectionList, StyleSheet, View } from 'react-native' import SectionHead from 'src/components/SectionHead' import GetStarted from 'src/home/GetStarted' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import colors from 'src/styles/colors' diff --git a/src/transactions/feed/TransferFeedItem.tsx b/src/transactions/feed/TransferFeedItem.tsx index 9c740ebce2c..6f572ff3eef 100644 --- a/src/transactions/feed/TransferFeedItem.tsx +++ b/src/transactions/feed/TransferFeedItem.tsx @@ -1,7 +1,6 @@ import BigNumber from 'bignumber.js' import React from 'react' import { StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import { HomeEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { hideHomeBalancesSelector } from 'src/app/selectors' @@ -9,6 +8,7 @@ import TokenDisplay from 'src/components/TokenDisplay' import Touchable from 'src/components/Touchable' import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' +import { useSelector } from 'src/redux/hooks' import { getFeatureGate } from 'src/statsig' import { StatsigFeatureGates } from 'src/statsig/types' import colors from 'src/styles/colors' diff --git a/src/transactions/feed/detailContent/RewardReceivedContent.tsx b/src/transactions/feed/detailContent/RewardReceivedContent.tsx index b4fad32f477..8a01d860916 100644 --- a/src/transactions/feed/detailContent/RewardReceivedContent.tsx +++ b/src/transactions/feed/detailContent/RewardReceivedContent.tsx @@ -2,7 +2,6 @@ import BigNumber from 'bignumber.js' import React from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text } from 'react-native' -import { useSelector } from 'react-redux' import { RewardsEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { rewardsEnabledSelector } from 'src/app/selectors' @@ -14,6 +13,7 @@ import { RewardsScreenOrigin } from 'src/consumerIncentives/analyticsEventsTrack import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { RecipientType } from 'src/recipients/recipient' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import TransferAvatars from 'src/transactions/TransferAvatars' diff --git a/src/transactions/feed/detailContent/TransferReceivedContent.tsx b/src/transactions/feed/detailContent/TransferReceivedContent.tsx index 8c7bc8940a7..42ee0e55881 100644 --- a/src/transactions/feed/detailContent/TransferReceivedContent.tsx +++ b/src/transactions/feed/detailContent/TransferReceivedContent.tsx @@ -8,16 +8,16 @@ import { navigate } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { getRecipientFromAddress } from 'src/recipients/recipient' import { recipientInfoSelector } from 'src/recipients/reducer' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { useTokenInfo } from 'src/tokens/hooks' -import networkConfig from 'src/web3/networkConfig' import CommentSection from 'src/transactions/CommentSection' import TransferAvatars from 'src/transactions/TransferAvatars' -import { TokenTransfer } from 'src/transactions/types' import UserSection from 'src/transactions/UserSection' +import { TokenTransfer } from 'src/transactions/types' import { Currency } from 'src/utils/currencies' +import networkConfig from 'src/web3/networkConfig' // Note that this is tested from TransactionDetailsScreen.test.tsx function TransferReceivedContent({ transfer }: { transfer: TokenTransfer }) { diff --git a/src/transactions/feed/detailContent/TransferSentContent.tsx b/src/transactions/feed/detailContent/TransferSentContent.tsx index 23f9094e1a6..4b9ca44b5ce 100644 --- a/src/transactions/feed/detailContent/TransferSentContent.tsx +++ b/src/transactions/feed/detailContent/TransferSentContent.tsx @@ -7,7 +7,7 @@ import LineItemRow from 'src/components/LineItemRow' import TokenDisplay from 'src/components/TokenDisplay' import { getRecipientFromAddress } from 'src/recipients/recipient' import { recipientInfoSelector } from 'src/recipients/reducer' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/transactions/feed/queryHelper.ts b/src/transactions/feed/queryHelper.ts index ab7b78899d3..0daf0e20b18 100644 --- a/src/transactions/feed/queryHelper.ts +++ b/src/transactions/feed/queryHelper.ts @@ -3,11 +3,11 @@ import { useEffect, useState } from 'react' import { useAsync } from 'react-async-hook' import { useTranslation } from 'react-i18next' import Toast from 'react-native-simple-toast' -import { useDispatch, useSelector } from 'react-redux' import { showError } from 'src/alert/actions' import { ErrorMessages } from 'src/app/ErrorMessages' import useInterval from 'src/hooks/useInterval' import { getLocalCurrencyCode } from 'src/localCurrency/selectors' +import { useDispatch, useSelector } from 'src/redux/hooks' import { DynamicConfigs } from 'src/statsig/constants' import { getDynamicConfigParams } from 'src/statsig/index' import { StatsigDynamicConfigs } from 'src/statsig/types' diff --git a/src/transactions/transferFeedUtils.ts b/src/transactions/transferFeedUtils.ts index 41a3997d98e..adb269bf02e 100644 --- a/src/transactions/transferFeedUtils.ts +++ b/src/transactions/transferFeedUtils.ts @@ -30,7 +30,7 @@ import { recipientInfoSelector, rewardsSendersSelector, } from 'src/recipients/reducer' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { useTokenInfoByAddress } from 'src/tokens/hooks' import { FeedTokenTransfer } from 'src/transactions/feed/TransferFeedItem' import { diff --git a/src/utils/countryFeatures.ts b/src/utils/countryFeatures.ts index 2b39826c221..8139c8fc833 100644 --- a/src/utils/countryFeatures.ts +++ b/src/utils/countryFeatures.ts @@ -1,7 +1,7 @@ import { createSelector } from 'reselect' import { countryFeatures } from 'src/flags' import { userLocationDataSelector } from 'src/networkInfo/selectors' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' type CountryFeatures = typeof countryFeatures type SpecificCountryFeatures = { [K in keyof CountryFeatures]: boolean } diff --git a/src/verify/VerificationStartScreen.tsx b/src/verify/VerificationStartScreen.tsx index 8f0d7703d8e..d9bd865deaa 100644 --- a/src/verify/VerificationStartScreen.tsx +++ b/src/verify/VerificationStartScreen.tsx @@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next' import { ActivityIndicator, BackHandler, StyleSheet, Text, View } from 'react-native' import * as RNLocalize from 'react-native-localize' import { SafeAreaView } from 'react-native-safe-area-context' -import { useDispatch, useSelector } from 'react-redux' import { initializeAccount } from 'src/account/actions' import { choseToRestoreAccountSelector, @@ -37,7 +36,7 @@ import { onboardingPropsSelector, } from 'src/onboarding/steps' import { retrieveSignedMessage } from 'src/pincode/authentication' -import useTypedSelector from 'src/redux/useSelector' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' @@ -65,7 +64,7 @@ function VerificationStartScreen({ const cachedNumber = useSelector(e164NumberSelector) const cachedCountryCallingCode = useSelector(defaultCountryCodeSelector) const walletAddress = useSelector(walletAddressSelector) - const onboardingProps = useTypedSelector(onboardingPropsSelector) + const onboardingProps = useSelector(onboardingPropsSelector) const { step, totalSteps } = getOnboardingStepValues( Screens.VerificationStartScreen, onboardingProps diff --git a/src/verify/hooks.ts b/src/verify/hooks.ts index 554ca127b7f..f5b17227b43 100644 --- a/src/verify/hooks.ts +++ b/src/verify/hooks.ts @@ -5,22 +5,22 @@ import { useEffect, useRef, useState } from 'react' import { useAsync, useAsyncCallback } from 'react-async-hook' import { Platform } from 'react-native' import DeviceInfo from 'react-native-device-info' -import { useDispatch, useSelector } from 'react-redux' import { e164NumberSelector } from 'src/account/selectors' import { showError } from 'src/alert/actions' import { PhoneVerificationEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' -import { phoneNumberRevoked, phoneNumberVerificationCompleted } from 'src/app/actions' import { ErrorMessages } from 'src/app/ErrorMessages' +import { phoneNumberRevoked, phoneNumberVerificationCompleted } from 'src/app/actions' import { inviterAddressSelector } from 'src/app/selectors' import { PHONE_NUMBER_VERIFICATION_CODE_LENGTH } from 'src/config' import { + SmsEvent, addSmsListener, removeSmsListener, - SmsEvent, startSmsRetriever, } from 'src/identity/smsRetrieval' import { retrieveSignedMessage } from 'src/pincode/authentication' +import { useDispatch, useSelector } from 'src/redux/hooks' import Logger from 'src/utils/Logger' import networkConfig from 'src/web3/networkConfig' import { dataEncryptionKeySelector, walletAddressSelector } from 'src/web3/selectors' diff --git a/src/walletConnect/screens/ActionRequest.tsx b/src/walletConnect/screens/ActionRequest.tsx index 44b038fffa2..c730fd30e9e 100644 --- a/src/walletConnect/screens/ActionRequest.tsx +++ b/src/walletConnect/screens/ActionRequest.tsx @@ -3,8 +3,8 @@ import { Web3WalletTypes } from '@walletconnect/web3wallet' import React, { useMemo } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import InLineNotification, { Severity } from 'src/components/InLineNotification' +import { useDispatch, useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' import { Spacing } from 'src/styles/styles' import Logger from 'src/utils/Logger' diff --git a/src/walletConnect/screens/ActionRequestPayload.tsx b/src/walletConnect/screens/ActionRequestPayload.tsx index b005a2dc636..47a5a925bf4 100644 --- a/src/walletConnect/screens/ActionRequestPayload.tsx +++ b/src/walletConnect/screens/ActionRequestPayload.tsx @@ -3,11 +3,11 @@ import { SessionTypes } from '@walletconnect/types' import { Web3WalletTypes } from '@walletconnect/web3wallet' import React, { useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { useSelector } from 'react-redux' import { WalletConnectEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import DataFieldWithCopy from 'src/components/DataFieldWithCopy' import { activeDappSelector } from 'src/dapps/selectors' +import { useSelector } from 'src/redux/hooks' import { SerializableTransactionRequest } from 'src/viem/preparedTransactionSerialization' import { getDefaultRequestTrackedProperties, diff --git a/src/walletConnect/screens/EstimatedNetworkFee.tsx b/src/walletConnect/screens/EstimatedNetworkFee.tsx index 6e81520acd5..33f66e096e8 100644 --- a/src/walletConnect/screens/EstimatedNetworkFee.tsx +++ b/src/walletConnect/screens/EstimatedNetworkFee.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' import TokenDisplay from 'src/components/TokenDisplay' -import useSelector from 'src/redux/useSelector' +import { useSelector } from 'src/redux/hooks' import { NETWORK_NAMES } from 'src/shared/conts' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' diff --git a/src/walletConnect/screens/RequestContent.tsx b/src/walletConnect/screens/RequestContent.tsx index 575f7c3230b..f86362fc32a 100644 --- a/src/walletConnect/screens/RequestContent.tsx +++ b/src/walletConnect/screens/RequestContent.tsx @@ -3,9 +3,9 @@ import { CoreTypes } from '@walletconnect/types' import React, { ReactElement, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' -import { useSelector } from 'react-redux' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' import { activeDappSelector } from 'src/dapps/selectors' +import { useSelector } from 'src/redux/hooks' import { Colors } from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/walletConnect/screens/SessionRequest.tsx b/src/walletConnect/screens/SessionRequest.tsx index 2b42c14341e..cfc7ae6d232 100644 --- a/src/walletConnect/screens/SessionRequest.tsx +++ b/src/walletConnect/screens/SessionRequest.tsx @@ -4,8 +4,8 @@ import { Web3WalletTypes } from '@walletconnect/web3wallet' import React from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import InLineNotification, { Severity } from 'src/components/InLineNotification' +import { useDispatch, useSelector } from 'src/redux/hooks' import { SentryTransactionHub } from 'src/sentry/SentryTransactionHub' import { SentryTransaction } from 'src/sentry/SentryTransactions' import { NETWORK_NAMES } from 'src/shared/conts' diff --git a/src/walletConnect/screens/Sessions.tsx b/src/walletConnect/screens/Sessions.tsx index f2207ad74e5..56282713884 100644 --- a/src/walletConnect/screens/Sessions.tsx +++ b/src/walletConnect/screens/Sessions.tsx @@ -2,11 +2,11 @@ import { CoreTypes, SessionTypes } from '@walletconnect/types' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { Image, ScrollView, StyleSheet, Text, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' import Dialog from 'src/components/Dialog' import QrScanButton from 'src/components/QrScanButton' import Touchable from 'src/components/Touchable' import { headerWithBackButton } from 'src/navigator/Headers' +import { useDispatch, useSelector } from 'src/redux/hooks' import colors from 'src/styles/colors' import fontStyles from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' diff --git a/src/walletConnect/screens/useIsDappListed.ts b/src/walletConnect/screens/useIsDappListed.ts index 345a49f8b2d..b7cd9b3d88c 100644 --- a/src/walletConnect/screens/useIsDappListed.ts +++ b/src/walletConnect/screens/useIsDappListed.ts @@ -1,5 +1,5 @@ -import { useSelector } from 'react-redux' import { dappsListSelector } from 'src/dapps/selectors' +import { useSelector } from 'src/redux/hooks' export const useIsDappListed = (dappUrl?: string) => { const dappsList = useSelector(dappsListSelector) diff --git a/src/webview/WebViewScreen.tsx b/src/webview/WebViewScreen.tsx index dcc89a91ad7..921699e591b 100644 --- a/src/webview/WebViewScreen.tsx +++ b/src/webview/WebViewScreen.tsx @@ -12,7 +12,6 @@ import { } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' import { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes' -import { useDispatch, useSelector } from 'react-redux' import { DappExplorerEvents, WebViewEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { openDeepLink } from 'src/app/actions' @@ -29,13 +28,14 @@ import { navigateBack } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { TopBarTextButton } from 'src/navigator/TopBarButton' import { StackParamList } from 'src/navigator/types' +import { useDispatch, useSelector } from 'src/redux/hooks' import { getDynamicConfigParams } from 'src/statsig' import { DynamicConfigs } from 'src/statsig/constants' import { StatsigDynamicConfigs } from 'src/statsig/types' import colors from 'src/styles/colors' import { iconHitslop } from 'src/styles/variables' -import { navigateToURI } from 'src/utils/linking' import Logger from 'src/utils/Logger' +import { navigateToURI } from 'src/utils/linking' import useBackHandler from 'src/utils/useBackHandler' import { isWalletConnectDeepLink } from 'src/walletConnect/walletConnect' import { WebViewAndroidBottomSheet } from 'src/webview/WebViewAndroidBottomSheet' diff --git a/yarn.lock b/yarn.lock index 35dac43ff58..6234d0aab29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1040,7 +1040,7 @@ resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310" integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA== -"@babel/runtime@^7.0.0", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.20.0", "@babel/runtime@^7.20.6", "@babel/runtime@^7.21.0", "@babel/runtime@^7.4.4", "@babel/runtime@^7.6.3", "@babel/runtime@^7.8.4": +"@babel/runtime@^7.0.0", "@babel/runtime@^7.12.5", "@babel/runtime@^7.20.0", "@babel/runtime@^7.20.6", "@babel/runtime@^7.21.0", "@babel/runtime@^7.4.4", "@babel/runtime@^7.6.3", "@babel/runtime@^7.8.4": version "7.22.11" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.11.tgz#7a9ba3bbe406ad6f9e8dd4da2ece453eb23a77a4" integrity sha512-ee7jVNlWN09+KftVOu9n7S8gQzD/Z6hN/I8VBRXW4P1+Xe7kJGXMwu8vds4aGIMHZnNbdpSWCfZZtinytpcAvA== @@ -4733,10 +4733,10 @@ resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.36.tgz#17ce0a235e9ffbcdcdf5095646b374c2bf615a4c" integrity sha512-7TUK/k2/QGpEAv/BCwSHlYu3NXZhQ9ZwBYpzr9tjlPIL2C5BeGhH3DmVavRx3ZNyELX5TLC91JTz/cen6AAtIQ== -"@types/hoist-non-react-statics@^3.3.0": - version "3.3.1" - resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" - integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA== +"@types/hoist-non-react-statics@^3.3.5": + version "3.3.5" + resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.5.tgz#dab7867ef789d87e2b4b0003c9d65c49cc44a494" + integrity sha512-SbcrWzkKBw2cdwRTwQAswfpB9g9LJWfjtUeW/jvNwbhC8cpmmNYVePa+ncbUe0rGTQ7G3Ff6mYUN2VMfLVr+Sg== dependencies: "@types/react" "*" hoist-non-react-statics "^3.3.0" @@ -4908,16 +4908,6 @@ dependencies: "@types/react" "*" -"@types/react-redux@^7.1.20", "@types/react-redux@^7.1.7": - version "7.1.25" - resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.25.tgz#de841631205b24f9dfb4967dd4a7901e048f9a88" - integrity sha512-bAGh4e+w5D8dajd6InASVIyCo4pZLJ66oLb80F9OBLO1gKESbZcRCJpTT6uLXX+HAB57zw1WTdwJdAsewuTweg== - dependencies: - "@types/hoist-non-react-statics" "^3.3.0" - "@types/react" "*" - hoist-non-react-statics "^3.3.0" - redux "^4.0.0" - "@types/react-test-renderer@^18.0.0": version "18.0.0" resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-18.0.0.tgz#7b7f69ca98821ea5501b21ba24ea7b6139da2243" @@ -4996,6 +4986,11 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff" integrity sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw== +"@types/use-sync-external-store@^0.0.3": + version "0.0.3" + resolved "https://registry.yarnpkg.com/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz#b6725d5f4af24ace33b36fafd295136e75509f43" + integrity sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA== + "@types/utf8@^2.1.6": version "2.1.6" resolved "https://registry.yarnpkg.com/@types/utf8/-/utf8-2.1.6.tgz#430cabb71a42d0a3613cce5621324fe4f5a25753" @@ -14888,7 +14883,7 @@ react-i18next@^12.3.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== -react-is@^17.0.1, react-is@^17.0.2: +react-is@^17.0.1: version "17.0.2" resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== @@ -15330,17 +15325,13 @@ react-native@0.71.12: whatwg-fetch "^3.0.0" ws "^6.2.2" -react-redux@^7.2.9: - version "7.2.9" - resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.2.9.tgz#09488fbb9416a4efe3735b7235055442b042481d" - integrity sha512-Gx4L3uM182jEEayZfRbI/G11ZpYdNAnBs70lFVMNdHJI76XYtR+7m0MN+eAs7UHBPhWXcnFPaS+9owSCJQHNpQ== +react-redux@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-9.1.0.tgz#46a46d4cfed4e534ce5452bb39ba18e1d98a8197" + integrity sha512-6qoDzIO+gbrza8h3hjMA9aq4nwVFCKFtY2iLxCtVT38Swyy2C/dJCGBXHeHLtx6qlg/8qzc2MrhOeduf5K32wQ== dependencies: - "@babel/runtime" "^7.15.4" - "@types/react-redux" "^7.1.20" - hoist-non-react-statics "^3.3.2" - loose-envify "^1.4.0" - prop-types "^15.7.2" - react-is "^17.0.2" + "@types/use-sync-external-store" "^0.0.3" + use-sync-external-store "^1.0.0" react-refresh@^0.4.0: version "0.4.2" @@ -15580,7 +15571,7 @@ redux-thunk@^3.1.0: resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-3.1.0.tgz#94aa6e04977c30e14e892eae84978c1af6058ff3" integrity sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw== -redux@^4.0.0, redux@^4.0.5, redux@^5.0.1: +redux@^4.0.5, redux@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/redux/-/redux-5.0.1.tgz#97fa26881ce5746500125585d5642c77b6e9447b" integrity sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==