@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
25 lines • 1.25 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityProvider = exports.EntityContext = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const useEntityData_1 = __importDefault(require("../hooks/entities/useEntityData"));
exports.EntityContext = (0, react_1.createContext)({});
const EntityProvider = ({ children, ...restOfProps }) => {
const data = (0, useEntityData_1.default)(restOfProps);
if (!('foreignId' in restOfProps && restOfProps.foreignId) &&
!('entityId' in restOfProps && restOfProps.entityId) &&
!('shortId' in restOfProps && restOfProps.shortId) &&
!('entity' in restOfProps && restOfProps.entity?.id)) {
// console.warn(
// "Please pass an entity ID, reference ID, short ID or a complete entity object to the EntityProvider"
// );
return null;
}
return ((0, jsx_runtime_1.jsx)(exports.EntityContext.Provider, { value: data, children: children }));
};
exports.EntityProvider = EntityProvider;
//# sourceMappingURL=entity-context.js.map