bigbuffet-rw/app/soapbox/hooks/useCompose.ts
marcin mikolajczak 6cce0a0291 Introduce useCompose hook
Signed-off-by: marcin mikolajczak <git@mkljczk.pl>
2022-09-14 20:01:44 +02:00

8 lines
406 B
TypeScript

import { useAppSelector } from 'soapbox/hooks';
import type { ReducerCompose } from 'soapbox/reducers/compose';
/** Get compose for given key with fallback to 'default' */
export const useCompose = <ID extends string>(composeId: ID extends 'default' ? never : ID): ReturnType<typeof ReducerCompose> => {
return useAppSelector((state) => state.compose.get(composeId, state.compose.get('default')!));
};