layout
layout copied to clipboard
The LayoutText component's view does not update when the text property is changed
The LayoutText component's view does not update when the text property is changed
Hey @khmer-chi do you have an example of this happening?
Hey @khmer-chi do you have an example of this happening?
plz check this repo,thx sir https://github.com/khmer-chi/pixi-layout-text-bug-report
There is a temporary workaround for this bug:
import { useEffect, useRef } from "react";
import { extend } from "@pixi/react";
import { LayoutText as LayoutTextComponent } from "@pixi/layout/components";
extend({
LayoutTextComponent,
});
export default function LayoutText({ text, layout, style }: { text: string, layout: any, style: any }) {
const layoutRef = useRef<LayoutTextComponent>(null);
useEffect(() => {
if (layoutRef.current) {
layoutRef.current.slot.text = text;
}
}, [text]);
return (
<layoutText ref={layoutRef} text={text} layout={layout} style={style} />
)
}