This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const useVideo = (videoRef: RefObject<HTMLVideoElement>, device: MediaDeviceInfo) => { | |
const [started, setStarted] = useState(false); | |
useEffect(() => { | |
if (!videoRef.current || !device) { | |
return noop; | |
} | |
const videoService = new VideoService(); | |
const start = async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect, useState, MutableRefObject} from 'react'; | |
import {Map, TileLayer} from 'leaflet'; | |
import {City} from '../types/city'; | |
function useMap( | |
mapRef: MutableRefObject<HTMLElement | null>, | |
city: City | |
): Map | null { | |
const [map, setMap] = useState<Map | null>(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Map = (props: PropsMap) => { | |
... | |
useEffect(() => { | |
if (!map) { | |
return; | |
} | |
const layerGroup = new LayerGroup(); | |
points.forEach((point) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Auth провайдер, обертка для прокидывания информации о пользователе | |
const AuthProvider = ({ children }) => { | |
const currentUser = JSON.parse(localStorage.getItem('user')); | |
const [user, setUser] = useState(currentUser ? { username: currentUser.username } : null); | |
const logIn = (userData) => { | |
localStorage.setItem('user', JSON.stringify(userData)); | |
setUser({ username: userData.username }); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withAcknowledgement = (socketFunc) => (...args) => new Promise((resolve, reject) => { | |
let state = 'pending'; // eslint-disable-line | |
const timer = setTimeout(() => { | |
state = 'rejected'; | |
reject(); | |
}, 3000); | |
socketFunc(...args, (response) => { | |
if (state !== 'pending') return; |
OlderNewer