Module: hooks
Functions
useGenerateAbsoluteLocalePath
▸ useGenerateAbsoluteLocalePath(): (path
: string
, params
: Record
<string
, string
| number
>) => string
Intended to use in the emails
Returns
fn
▸ (path
, params?
): string
Parameters
Name | Type |
---|---|
path | string |
params | Record <string , string | number > |
Returns
string
Defined in
useGenerateLocalePath
▸ useGenerateLocalePath(): (path
: string
, params
: Record
<string
, string
| number
>) => string
A hook that returns a function you can use to generate a path that includes proper locale code. Underneath, it uses
generatePath
function exported by
react-router-dom
.
Returns
fn
▸ (path
, params?
): string
Parameters
Name | Type |
---|---|
path | string |
params | Record <string , string | number > |
Returns
string
Example
import { useGenerateLocalePath } from '@shipfast/webapp-core/hooks';
import { Link } from 'react-router-dom';
const Example = () => {
const generateLocalePath = useGenerateLocalePath();
return (
<Link to={generateLocalePath(RoutesConfig.example.edit, { id: 'item-id' })}>
Press me
</Link>
)
}
Defined in
packages/webapp-libs/webapp-core/src/hooks/useGenerateLocalePath/useGenerateLocalePath.ts:30
useLocale
▸ useLocale(): Locale
Returns
Locale
Defined in
packages/webapp-libs/webapp-core/src/hooks/useLocale/useLocale.hook.ts:9
useLocales
▸ useLocales(): Object
Returns
Object
Name | Type |
---|---|
locales | LocalesState |
setLanguage | (language : Locale ) => void |
Defined in
packages/webapp-libs/webapp-core/src/hooks/useLocales/useLocales.hooks.ts:6
useMappedConnection
▸ useMappedConnection<ITEM
>(data?
): ITEM
[]
Type parameters
Name |
---|
ITEM |
Parameters
Name | Type |
---|---|
data? | ConnectionType <ITEM > |
Returns
ITEM
[]
Defined in
packages/webapp-libs/webapp-core/src/hooks/useMappedConnection/useMappedConnection.hook.ts:6
useMediaQuery
▸ useMediaQuery(«destructured»
): QueryResult
useMediaQuery({above: Breakpoint.DESKTOP}); => true for desktop and above, false otherwise useMediaQuery({below: Breakpoint.DESKTOP}); => true for desktop and below, false otherwise useMediaQuery({matches: Breakpoint.DESKTOP}); => true for desktop, false otherwise useMediaQuery({matches: [Breakpoint.DESKTOP, Breakpoint.MOBILE]}); => true for desktop and mobile, false otherwise
Parameters
Name | Type |
---|---|
«destructured» | BreakpointQuery |
Returns
QueryResult
Defined in
packages/webapp-libs/webapp-core/src/hooks/useMediaQuery/useMediaQuery.hook.ts:21
useOpenState
▸ useOpenState(initialValue
): Object
Parameters
Name | Type |
---|---|
initialValue | boolean | () => boolean |
Returns
Object
Name | Type |
---|---|
clickAway | () => void |
close | () => void |
isOpen | boolean |
open | () => void |
setIsOpen | Dispatch <SetStateAction <boolean >> |
toggle | () => void |
Defined in
packages/webapp-libs/webapp-core/src/hooks/useOpenState/useOpenState.hook.ts:9
useWindowListener
▸ useWindowListener(eventType
, callback
, «destructured»
): void
Parameters
Name | Type |
---|---|
eventType | string |
callback | (...args : unknown []) => void |
«destructured» | { throttle? : number } & UnknownObject |
Returns
void
Defined in
packages/webapp-libs/webapp-core/src/hooks/useWindowListener/useWindowListener.hook.ts:5