@kietpt2003/react-native-core-ui
Version:
React Native Core UI components by KietPT
20 lines (19 loc) • 830 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
const DraggableFlatListContext = React.createContext(undefined);
export default function DraggableFlatListProvider({ activeKey, keyExtractor, horizontal, layoutAnimationDisabled, children, }) {
const value = React.useMemo(() => ({
activeKey,
keyExtractor,
horizontal,
layoutAnimationDisabled,
}), [activeKey, keyExtractor, horizontal, layoutAnimationDisabled]);
return (_jsx(DraggableFlatListContext.Provider, { value: value, children: children }));
}
export function useDraggableFlatListContext() {
const value = React.useContext(DraggableFlatListContext);
if (!value) {
throw new Error("useDraggableFlatListContext must be called within DraggableFlatListProvider");
}
return value;
}