Skip to content

Instantly share code, notes, and snippets.

ansh / fontWeightToFontFamily.tsx
Created December 14, 2022 13:17
Map fontWeight to fontFamily for custom fonts in React Native with pure TypeScript
// This is a little code snippet I found useful for adding custom fonts to your React Native / Expo project.
// The essential idea is that we map fontWeight to fontFamily via a simple function and some TypeScript magic. We can also make it faster by wrapping the function in a useMemo hook
// Here is the mappings of fontWeight to fontFamily for your custom font
export const Poppins = {
"100": "Poppins_100Thin",
"200": "Poppins_200ExtraLight",
"300": "Poppins_300Light",
"400": "Poppins_400Regular",