Skip to content

Commit 28602e6

Browse files
fix: only rerender text, not the whole textbox component.
1 parent 57bb0b3 commit 28602e6

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ export const TextPreview = (props: any) => {
3030

3131
const Textbox = IMSSTextbox;
3232

33+
const [previewKey, setPreviewKey] = useState<number>(0);
34+
35+
const forcePreviewUpdate = () => {
36+
setPreviewKey((prevKey) => prevKey + 1);
37+
};
38+
3339
const textboxProps = {
3440
textArray: previewTextArray,
3541
isText: true,
@@ -38,7 +44,7 @@ export const TextPreview = (props: any) => {
3844
showName: showNameArray,
3945
currentConcatDialogPrev: '',
4046
fontSize: size,
41-
currentDialogKey: '',
47+
currentDialogKey: String(previewKey),
4248
isSafari: isSafari,
4349
isFirefox: isFirefox,
4450
miniAvatar: '',
@@ -50,12 +56,6 @@ export const TextPreview = (props: any) => {
5056
textboxOpacity: textboxOpacity,
5157
};
5258

53-
const [previewKey, setPreviewKey] = useState<number>(0);
54-
55-
const forcePreviewUpdate = () => {
56-
setPreviewKey((prevKey) => prevKey + 1);
57-
};
58-
5959
return (
6060
<div
6161
className={styles.textPreviewMain}
@@ -65,7 +65,7 @@ export const TextPreview = (props: any) => {
6565
onClick={forcePreviewUpdate}
6666
>
6767
<div key={`previewTextbox-${textDelay}`} className={styles.textbox}>
68-
<Textbox key={previewKey} {...textboxProps} />
68+
<Textbox {...textboxProps} />
6969
</div>
7070
</div>
7171
);

0 commit comments

Comments
 (0)