Conform more of the codebase to strictNullChecks
(#10573)
* Conform more of the codebase to `strictNullChecks` * Iterate
This commit is contained in:
parent
b4d7f6b592
commit
605ef084ec
34 changed files with 119 additions and 104 deletions
|
@ -28,8 +28,8 @@ const defaultMapper: Mapper<RoomState> = (roomState: RoomState) => roomState;
|
|||
export const useRoomState = <T extends any = RoomState>(
|
||||
room?: Room,
|
||||
mapper: Mapper<T> = defaultMapper as Mapper<T>,
|
||||
): T | undefined => {
|
||||
const [value, setValue] = useState<T | undefined>(room ? mapper(room.currentState) : undefined);
|
||||
): T => {
|
||||
const [value, setValue] = useState<T>(room ? mapper(room.currentState) : (undefined as T));
|
||||
|
||||
const update = useCallback(() => {
|
||||
if (!room) return;
|
||||
|
@ -40,8 +40,8 @@ export const useRoomState = <T extends any = RoomState>(
|
|||
useEffect(() => {
|
||||
update();
|
||||
return () => {
|
||||
setValue(undefined);
|
||||
setValue(room ? mapper(room.currentState) : (undefined as T));
|
||||
};
|
||||
}, [update]);
|
||||
}, [room, mapper, update]);
|
||||
return value;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue