"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useCommunity = void 0;
var _react = require("react");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
const useCommunity = communityId => {
  const [loading, setLoading] = (0, _react.useState)(true);
  const [community, setCommunity] = (0, _react.useState)();
  (0, _react.useEffect)(() => {
    const unsubscribe = _tsSdkReactNative.CommunityRepository.getCommunity(communityId, ({
      error,
      loading,
      data
    }) => {
      setLoading(loading);
      if (error) return;
      if (!loading) {
        setCommunity(data);
      }
    });
    return () => {
      unsubscribe();
    };
  }, [communityId]);
  return {
    community,
    loading
  };
};
exports.useCommunity = useCommunity;
//# sourceMappingURL=useCommunity.js.map