Skip to content

Commit 3cc6189

Browse files
Theme: replacing code with custom hook
1 parent b4cd202 commit 3cc6189

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

client/packages/lowcoder/src/comps/comps/textComp.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { CompTypeContext } from "../utils/compTypeContext";
2828
import { changeChildAction } from "lowcoder-core";
2929
import { setInitialCompStyles } from "../utils/themeUtil";
3030
import { BoolControl } from "../controls/boolControl";
31+
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
3132

3233
const getStyle = (style: TextStyleType) => {
3334
return css`
@@ -142,27 +143,14 @@ let TextTmpComp = (function () {
142143
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
143144
margin: MarginControl,
144145
padding: PaddingControl,
145-
themeApplied: BoolControl,
146146
};
147147
return new UICompBuilder(childrenMap, (props, dispatch) => {
148148
const value = props.text.value;
149-
const theme = useContext(ThemeContext);
150-
const compType = useContext(CompTypeContext);
151-
const compTheme = theme?.theme?.components?.[compType];
152-
153-
const styleProps: Record<string, any> = {};
154-
['style', 'animationStyle'].forEach((key: string) => {
155-
styleProps[key] = (props as any)[key];
156-
});
157149

158-
useEffect(() => {
159-
if (props.themeApplied) return;
160-
setInitialCompStyles({
161-
dispatch,
162-
compTheme,
163-
styleProps,
164-
});
165-
}, []);
150+
useMergeCompStyles(
151+
props as Record<string, any>,
152+
dispatch
153+
);
166154

167155
return (
168156
<TextContainer

0 commit comments

Comments
 (0)