UNPKG

@pdf-viewer/react

Version:

A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.

20 lines (19 loc) 718 B
import { jsx as u } from "react/jsx-runtime"; import { createContext as s, useContext as c, useState as i, useEffect as l } from "react"; import { useInitialStateContext as C } from "./InitialStateContext.js"; import { useEventCallbackContext as P } from "./EventCallbackContext.js"; const n = s({ currentPage: 1, setCurrentPage: () => { } }), p = () => c(n), b = ({ children: r }) => { const { initialPage: o = 1 } = C(), [t, a] = i(o), { onPageChange: e } = P(); return l(() => { e && e(t); }, [t, e]), /* @__PURE__ */ u(n.Provider, { value: { currentPage: t, setCurrentPage: a }, children: r }); }; export { n as GlobalCurrentPage, b as GlobalCurrentPageProvider, p as useGlobalCurrentPage };