@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
33 lines • 1.42 kB
JavaScript
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
import { useEffect } from "react";
import { Provider, useDispatch } from "react-redux";
import { replykeStore } from "../store";
import { initializeAuthThunk } from "../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 = useDispatch();
useEffect(function () {
// Initialize auth with project and signed token
dispatch(initializeAuthThunk({
projectId: projectId,
signedToken: signedToken
}));
}, [dispatch, projectId, signedToken]);
return _jsx(_Fragment, { children: children });
};
/**
* Redux store provider for Replyke
* This component provides the Redux store and initializes auth state
*/
export var ReplykeStoreProvider = function (_a) {
var children = _a.children, projectId = _a.projectId, signedToken = _a.signedToken;
return (_jsx(Provider, { store: replykeStore, children: _jsx(AuthInitializer, { projectId: projectId, signedToken: signedToken, children: children }) }));
};
// Clean Redux-only architecture
// Always integrated with ReplykeProvider
export default ReplykeStoreProvider;
//# sourceMappingURL=replyke-store-context.js.map