diff --git a/example/src/pages/MainScreen.tsx b/example/src/pages/MainScreen.tsx
index dbad4c2d..0b8fd530 100644
--- a/example/src/pages/MainScreen.tsx
+++ b/example/src/pages/MainScreen.tsx
@@ -9,7 +9,8 @@ import {
ListItemNav,
useIOExperimentalDesign,
ListItemSwitch,
- useIOThemeContext
+ useIOThemeContext,
+ H3
} from "@pagopa/io-app-design-system";
import APP_ROUTES from "../navigation/routes";
import { AppParamsList } from "../navigation/params";
@@ -87,9 +88,16 @@ const MainScreen = (props: Props) => {
const renderDSSectionFooter = () => ;
+ const mRef = React.useRef(null);
+ React.useEffect(() => {
+ // eslint-disable-next-line no-console
+ console.log(`=== MainScreen ref (${mRef}) current (${mRef.current})`);
+ }, []);
+
return (
<>
+ {"Mio titolo"}
= props => {
+export const BaseTypography: React.FC = React.forwardRef<
+ View,
+ OwnProps
+>((props, ref) => {
const fontStyle = useMemo(
() =>
calculateTextStyle(props.color, props.weight, props.isItalic, props.font),
@@ -54,8 +57,8 @@ export const BaseTypography: React.FC = props => {
: [props.fontStyle, fontStyle];
return (
-
+
{props.children}
);
-};
+});
diff --git a/src/components/typography/Factory.tsx b/src/components/typography/Factory.tsx
index 9d562fd7..68d125fd 100644
--- a/src/components/typography/Factory.tsx
+++ b/src/components/typography/Factory.tsx
@@ -1,4 +1,5 @@
import React, { useMemo } from "react";
+import { View } from "react-native";
import { IOColors } from "../../core";
import { IOFontWeight } from "../../utils/fonts";
import { XOR } from "../../utils/types";
@@ -74,7 +75,10 @@ function isDefaultFactoryProps(
export function useTypographyFactory<
WeightPropsType extends IOFontWeight,
ColorsPropsType extends IOColors
->(props: FactoryProps) {
+>(
+ props: FactoryProps,
+ ref?: React.ForwardedRef
+) {
// Use different strategy to calculate the default values, based on DefaultProps
const { weight, color } = useMemo(
() =>
@@ -89,5 +93,5 @@ export function useTypographyFactory<
[props]
);
- return ;
+ return ;
}
diff --git a/src/components/typography/H3.tsx b/src/components/typography/H3.tsx
index 0e975ea4..3b44a56f 100644
--- a/src/components/typography/H3.tsx
+++ b/src/components/typography/H3.tsx
@@ -1,3 +1,5 @@
+import React from "react";
+import { View } from "react-native";
import { IOTheme, useIOExperimentalDesign } from "../../core";
import { FontFamily, IOFontWeight } from "../../utils/fonts";
import { useTypographyFactory } from "./Factory";
@@ -26,17 +28,20 @@ const legacyH3LineHeight = 34;
/**
* `H3` typographic style
*/
-export const H3 = (props: H3Props) => {
+export const H3 = React.forwardRef((props, ref) => {
const { isExperimental } = useIOExperimentalDesign();
- return useTypographyFactory({
- ...props,
- defaultWeight: isExperimental ? defaultWeight : legacyDefaultWeight,
- defaultColor: isExperimental ? defaultColor : legacyDefaultColor,
- font: isExperimental ? font : legacyFontName,
- fontStyle: {
- fontSize: isExperimental ? h3FontSize : legacyH3FontSize,
- lineHeight: isExperimental ? h3LineHeight : legacyH3LineHeight
- }
- });
-};
+ return useTypographyFactory(
+ {
+ ...props,
+ defaultWeight: isExperimental ? defaultWeight : legacyDefaultWeight,
+ defaultColor: isExperimental ? defaultColor : legacyDefaultColor,
+ font: isExperimental ? font : legacyFontName,
+ fontStyle: {
+ fontSize: isExperimental ? h3FontSize : legacyH3FontSize,
+ lineHeight: isExperimental ? h3LineHeight : legacyH3LineHeight
+ }
+ },
+ ref
+ );
+});