@tamagui/react-native-web-lite
Version:
React Native for Web
49 lines (48 loc) • 1.67 kB
JavaScript
import "../VirtualizedList";
import * as React from "react";
import { useContext, useMemo } from "react";
import { jsx } from "react/jsx-runtime";
const __DEV__ = process.env.NODE_ENV !== "production";
const VirtualizedListContext = React.createContext(null);
__DEV__ && (VirtualizedListContext.displayName = "VirtualizedListContext");
function VirtualizedListContextResetter({
children
}) {
return /* @__PURE__ */jsx(VirtualizedListContext.Provider, {
value: null,
children
});
}
function VirtualizedListContextProvider({
children,
value
}) {
const context = useMemo(() => ({
cellKey: null,
getScrollMetrics: value.getScrollMetrics,
horizontal: value.horizontal,
getOutermostParentListRef: value.getOutermostParentListRef,
registerAsNestedChild: value.registerAsNestedChild,
unregisterAsNestedChild: value.unregisterAsNestedChild
}), [value.getScrollMetrics, value.horizontal, value.getOutermostParentListRef, value.registerAsNestedChild, value.unregisterAsNestedChild]);
return /* @__PURE__ */jsx(VirtualizedListContext.Provider, {
value: context,
children
});
}
function VirtualizedListCellContextProvider({
cellKey,
children
}) {
const currContext = useContext(VirtualizedListContext),
context = useMemo(() => currContext == null ? null : {
...currContext,
cellKey
}, [currContext, cellKey]);
return /* @__PURE__ */jsx(VirtualizedListContext.Provider, {
value: context,
children
});
}
export { VirtualizedListCellContextProvider, VirtualizedListContext, VirtualizedListContextProvider, VirtualizedListContextResetter };
//# sourceMappingURL=VirtualizedListContext.mjs.map