Skip to main content

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
NameType
pathstring
paramsRecord<string, string | number>
Returns

string

Defined in

packages/webapp-libs/webapp-core/src/hooks/useGenerateAbsoluteLocalePath/useGenerateAbsoluteLocalePath.ts:10


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
NameType
pathstring
paramsRecord<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

NameType
localesLocalesState
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

NameType
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

NameType
«destructured»BreakpointQuery

Returns

QueryResult

Defined in

packages/webapp-libs/webapp-core/src/hooks/useMediaQuery/useMediaQuery.hook.ts:21


useOpenState

useOpenState(initialValue): Object

Parameters

NameType
initialValueboolean | () => boolean

Returns

Object

NameType
clickAway() => void
close() => void
isOpenboolean
open() => void
setIsOpenDispatch<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

NameType
eventTypestring
callback(...args: unknown[]) => void
«destructured»{ throttle?: number } & UnknownObject

Returns

void

Defined in

packages/webapp-libs/webapp-core/src/hooks/useWindowListener/useWindowListener.hook.ts:5