Files
cinny/src/app/hooks/useAccountData.ts
T
litruv a6ad8651b3
Checks / checks (push) Successful in 2m11s
Trigger cinny-mobile / dispatch (push) Successful in 1s
Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
2026-11-01 04:23:53 +11:00

23 lines
542 B
TypeScript

import { useState, useCallback } from 'react';
import { useMatrixClient } from './useMatrixClient';
import { useAccountDataCallback } from './useAccountDataCallback';
export function useAccountData(eventType: string) {
const mx = useMatrixClient();
const [event, setEvent] = useState(() => mx.getAccountData(eventType));
useAccountDataCallback(
mx,
useCallback(
(evt) => {
if (evt.getType() === eventType) {
setEvent(evt);
}
},
[eventType, setEvent],
),
);
return event;
}