-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtextDefaults.ts
More file actions
22 lines (20 loc) · 845 Bytes
/
textDefaults.ts
File metadata and controls
22 lines (20 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { cloneElement, type ReactElement } from "react";
import { Text, type TextProps } from "react-native";
// Apply Open Runde as the default fontFamily for every <Text>, including those
// imported directly from react-native. User-provided styles (e.g. font-mono via
// NativeWind className) appear later in the style array and override the default.
type PatchableText = {
render: (...args: unknown[]) => ReactElement<TextProps>;
__posthogPatched?: boolean;
};
const TextRef = Text as unknown as PatchableText;
if (!TextRef.__posthogPatched) {
const baseRender = TextRef.render;
TextRef.render = function patchedRender(...args) {
const element = baseRender.apply(this, args);
return cloneElement(element, {
style: [{ fontFamily: "Open Runde" }, element.props.style],
});
};
TextRef.__posthogPatched = true;
}