layout icon indicating copy to clipboard operation
layout copied to clipboard

The LayoutText component's view does not update when the text property is changed

Open khmer-chi opened this issue 6 months ago • 3 comments

The LayoutText component's view does not update when the text property is changed

khmer-chi avatar May 28 '25 09:05 khmer-chi

Hey @khmer-chi do you have an example of this happening?

Zyie avatar May 29 '25 12:05 Zyie

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

khmer-chi avatar May 30 '25 09:05 khmer-chi

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} />
  )
}

wcp1231 avatar Jun 30 '25 08:06 wcp1231