onStart and{" "}
onFinish callbacks (see log message
in the console)
Lorem ipsum dolor sit amet, consectetur
>
);
}
/**
* Example4 - recalculating on content change
*/
function Example4() {
const [text, setText] = useState("Lorem ipsum dolor sit amet, consectetur");
const { fontSize, ref } = useFitText();
return (
<>
Example 4 - recalculating on content change
Change the input text and the font size will be updated to fit the text
in the div
>
);
}
/**
* Example5 - fails to fit text because `fontSizeMin` is too big
*/
function Example5() {
const { fontSize, ref } = useFitText({
maxFontSize: 285.7142857142857,
minFontSize: 125.7142857142857,
// Note: with `v2.3.0` and earlier, adding this non-referentially equal
// `onFinish` callback caused a "Maximum update depth exceeded" error.
// See https://github.com/saltycrane/use-fit-text/issues/9
onFinish: () => {},
});
return (
<>
Example 5 - fails to fit text because fontSizeMin is too
big. Shows a message in the console.
Lorem ipsum dolor sit amet, consectetur Lorem ipsum dolor sit amet,
consectetur