diff --git a/packages/cra-template-typescript/template/src/hooks/index.ts b/packages/cra-template-typescript/template/src/hooks/index.ts index 7d7c2c5803f..492425ed2d3 100644 --- a/packages/cra-template-typescript/template/src/hooks/index.ts +++ b/packages/cra-template-typescript/template/src/hooks/index.ts @@ -1 +1,2 @@ export { default as useFelaEnhanced } from './useFelaEnhanced'; +export { useAppSelector, useAppDispatch } from './redux'; diff --git a/packages/cra-template-typescript/template/src/hooks/redux.ts b/packages/cra-template-typescript/template/src/hooks/redux.ts new file mode 100644 index 00000000000..e6149b49388 --- /dev/null +++ b/packages/cra-template-typescript/template/src/hooks/redux.ts @@ -0,0 +1,6 @@ +import { useDispatch, useSelector } from 'react-redux'; +import type { TypedUseSelectorHook } from 'react-redux'; +import type { RootState, AppDispatch } from 'modules/core'; + +export const useAppDispatch = () => useDispatch(); +export const useAppSelector: TypedUseSelectorHook = useSelector; diff --git a/packages/cra-template-typescript/template/src/modules/auth/components/AuthContent.tsx b/packages/cra-template-typescript/template/src/modules/auth/components/AuthContent.tsx index de46d1a2fb4..f7cf859249f 100644 --- a/packages/cra-template-typescript/template/src/modules/auth/components/AuthContent.tsx +++ b/packages/cra-template-typescript/template/src/modules/auth/components/AuthContent.tsx @@ -1,13 +1,13 @@ import React from "react"; import { FormattedMessage } from "react-intl"; -import { useDispatch, useSelector } from "react-redux"; import * as Petrus from "@ackee/petrus"; +import { useAppDispatch, useAppSelector } from "hooks"; import { userEmailSelector } from '../services/selectors'; function AuthContent() { - const dispatch = useDispatch(); - const userEmail = useSelector(userEmailSelector); + const dispatch = useAppDispatch(); + const userEmail = useAppSelector(userEmailSelector); return ( <> diff --git a/packages/cra-template-typescript/template/src/modules/core/modules/localization/components/LocalizationsAntd/LocalizationsAntd.tsx b/packages/cra-template-typescript/template/src/modules/core/modules/localization/components/LocalizationsAntd/LocalizationsAntd.tsx index cbf71c74661..4423a3ea0cf 100644 --- a/packages/cra-template-typescript/template/src/modules/core/modules/localization/components/LocalizationsAntd/LocalizationsAntd.tsx +++ b/packages/cra-template-typescript/template/src/modules/core/modules/localization/components/LocalizationsAntd/LocalizationsAntd.tsx @@ -2,8 +2,8 @@ import React from 'react'; import type { ReactNode } from 'react'; import ConfigProvider from 'antd/es/config-provider'; import type { Locale as AntdLocaleData } from 'antd/es/locale-provider'; -import { useSelector } from 'react-redux'; import { translateSelector } from '@ackee/jerome'; +import { useAppSelector } from 'hooks'; export interface LocalizationsAntdProps { antdLocaleData: Record; @@ -11,7 +11,7 @@ export interface LocalizationsAntdProps { } export const LocalizationsAntd = ({ antdLocaleData, children }: LocalizationsAntdProps) => { - const { locale } = useSelector(translateSelector); + const { locale } = useAppSelector(translateSelector); return {children}; }; diff --git a/packages/cra-template-typescript/template/src/modules/core/modules/localization/components/LocalizationsRaw/LocalizationsRaw.tsx b/packages/cra-template-typescript/template/src/modules/core/modules/localization/components/LocalizationsRaw/LocalizationsRaw.tsx index aac814803a4..0fad6593f30 100644 --- a/packages/cra-template-typescript/template/src/modules/core/modules/localization/components/LocalizationsRaw/LocalizationsRaw.tsx +++ b/packages/cra-template-typescript/template/src/modules/core/modules/localization/components/LocalizationsRaw/LocalizationsRaw.tsx @@ -2,8 +2,8 @@ import React from 'react'; import type { ReactNode } from 'react'; import { IntlProvider } from 'react-intl'; import type { IntlConfig } from 'react-intl'; -import { useSelector } from 'react-redux'; import { translateSelector } from '@ackee/jerome'; +import { useAppSelector } from 'hooks'; export interface LocalizationsRawProps { intlMessages: Record; @@ -12,7 +12,7 @@ export interface LocalizationsRawProps { } export const LocalizationsRaw = ({ intlMessages, children, onError }: LocalizationsRawProps) => { - const { locale } = useSelector(translateSelector); + const { locale } = useAppSelector(translateSelector); return (