UNPKG

@replyke/core

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

37 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReplykeStoreProvider = void 0; var jsx_runtime_1 = require("react/jsx-runtime"); var react_1 = require("react"); var react_redux_1 = require("react-redux"); var store_1 = require("../store"); var authThunks_1 = require("../store/slices/authThunks"); /** * Component that initializes auth state in Redux * Must be inside the Redux Provider to dispatch actions */ var AuthInitializer = function (_a) { var children = _a.children, projectId = _a.projectId, signedToken = _a.signedToken; var dispatch = (0, react_redux_1.useDispatch)(); (0, react_1.useEffect)(function () { // Initialize auth with project and signed token dispatch((0, authThunks_1.initializeAuthThunk)({ projectId: projectId, signedToken: signedToken })); }, [dispatch, projectId, signedToken]); return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }); }; /** * Redux store provider for Replyke * This component provides the Redux store and initializes auth state */ var ReplykeStoreProvider = function (_a) { var children = _a.children, projectId = _a.projectId, signedToken = _a.signedToken; return ((0, jsx_runtime_1.jsx)(react_redux_1.Provider, { store: store_1.replykeStore, children: (0, jsx_runtime_1.jsx)(AuthInitializer, { projectId: projectId, signedToken: signedToken, children: children }) })); }; exports.ReplykeStoreProvider = ReplykeStoreProvider; // Clean Redux-only architecture // Always integrated with ReplykeProvider exports.default = exports.ReplykeStoreProvider; //# sourceMappingURL=replyke-store-context.js.map