@roochnetwork/rooch-sdk-kit
Version:
Rooch SDK Kit
31 lines (27 loc) • 807 B
JavaScript
// src/hooks/useSessionsStore.ts
import { useContext } from "react";
import { useStore } from "zustand";
// src/provider/roochProvider.tsx
import { createContext, useRef } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
var RoochContext = createContext(null);
// src/hooks/useSessionsStore.ts
function useSessionStore(selector) {
const store = useContext(RoochContext);
if (!store) {
throw new Error(
"Could not find RoochSessionContext. Ensure that you have set up the RoochClientProvider."
);
}
return useStore(store, selector);
}
// src/hooks/useSessions.ts
function useSessions() {
return useSessionStore(
(state) => state.sessions.sort((a, b) => b.getCreateTime() - a.getCreateTime())
);
}
export {
useSessions
};
//# sourceMappingURL=useSessions.js.map