Fix typing

This commit is contained in:
Michael Telatynski 2021-06-22 22:19:01 +01:00
parent 1286be1ffb
commit 83296b7440

View File

@ -24,7 +24,10 @@ type Mapper<T> = (roomState: RoomState) => T;
const defaultMapper: Mapper<RoomState> = (roomState: RoomState) => roomState;
// Hook to simplify watching Matrix Room state
export const useRoomState = <T extends any = RoomState>(room: Room, mapper: Mapper<T> = defaultMapper): T => {
export const useRoomState = <T extends any = RoomState>(
room: Room,
mapper: Mapper<T> = defaultMapper as Mapper<T>,
): T => {
const [value, setValue] = useState<T>(room ? mapper(room.currentState) : undefined);
const update = useCallback(() => {