import { useEffect, useState } from 'react';
import { CommunityRepository } from '@amityco/ts-sdk-react-native';
export const useCommunity = communityId => {
  const [loading, setLoading] = useState(true);
  const [community, setCommunity] = useState();
  useEffect(() => {
    const unsubscribe = CommunityRepository.getCommunity(communityId, ({
      error,
      loading,
      data
    }) => {
      setLoading(loading);
      if (error) return;
      if (!loading) {
        setCommunity(data);
      }
    });
    return () => {
      unsubscribe();
    };
  }, [communityId]);
  return {
    community,
    loading
  };
};
//# sourceMappingURL=useCommunity.js.map