Files
lucide/packages/lucide-react-native/src/context.tsx
2025-12-12 10:52:32 +01:00

44 lines
906 B
TypeScript

import { createContext, type ReactNode, useContext, useMemo } from 'react';
const LucideContext = createContext<{
size?: number;
color?: string;
strokeWidth?: number;
absoluteStrokeWidth?: boolean;
}>({
size: 24,
color: 'currentColor',
strokeWidth: 2,
absoluteStrokeWidth: false,
});
interface LucideProviderProps {
children: ReactNode;
size?: number;
color?: string;
strokeWidth?: number;
absoluteStrokeWidth?: boolean;
}
export function LucideProvider({
children,
size,
color,
strokeWidth,
absoluteStrokeWidth,
}: LucideProviderProps) {
const value = useMemo(
() => ({
size,
color,
strokeWidth,
absoluteStrokeWidth,
}),
[size, color, strokeWidth, absoluteStrokeWidth],
);
return <LucideContext.Provider value={value}>{children}</LucideContext.Provider>;
}
export const useLucideContext = () => useContext(LucideContext);