The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/contexts/SessionContext.js

18 lines
522 B

import { createContext, useCallback, useContext } from 'react';
import { useObservableValue } from '../hooks/useObservableValue';
export const SessionContext = createContext({
get: () => {},
set: () => {},
});
export const useSession = (name) => {
const { get } = useContext(SessionContext);
return useObservableValue((listener) => get(name, listener));
};
export const useSessionDispatch = (name) => {
const { set } = useContext(SessionContext);
return useCallback((value) => set(name, value), [set, name]);
};