The main server, and probably only repository in this org.
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.

20 lines
422 B

5 years ago
5 years ago
5 years ago
  1. import {useEffect, useState} from "react";
  2. import {subscribeToGroup, unsubscribeFromGroup} from "../Helpers/groups";
  3. export default function useGroups(id = -1) {
  4. const [group, setGroup] = useState(null);
  5. function onChange(group) {
  6. setGroup(group);
  7. }
  8. useEffect(() => {
  9. const cbId = subscribeToGroup(id, onChange);
  10. return () => {
  11. unsubscribeFromGroup(cbId);
  12. };
  13. }, []);
  14. return group;
  15. }