Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ee2935

Browse files
memoize timer comp's view and propertyView
1 parentfb9eb33 commit0ee2935

File tree

1 file changed

+55
-46
lines changed

1 file changed

+55
-46
lines changed

‎client/packages/lowcoder/src/comps/comps/timerComp.tsx‎

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import{CompAction,RecordConstructorToView,changeChildAction}from"lowcoder-core";
1+
import{CompAction,RecordConstructorToComp,RecordConstructorToView,changeChildAction}from"lowcoder-core";
22
import{styleControl}from"comps/controls/styleControl";
33
import{AnimationStyle,AnimationStyleType,startButtonStyle,StartButtonStyleType,timerStyle,timerStyleType}from"comps/controls/styleControlConstants";
4-
import{UICompBuilder}from"comps/generators/uiCompBuilder";
4+
import{NewChildren,UICompBuilder}from"comps/generators/uiCompBuilder";
55
import{NameConfig,NameConfigHidden,withExposingConfigs}from"comps/generators/withExposing";
66
import{Section,sectionNames}from"lowcoder-design";
77
import{hiddenPropertyView,showDataLoadingIndicatorsPropertyView}from"comps/utils/propertyUtils";
@@ -15,6 +15,7 @@ import { EditorContext } from "comps/editorState";
1515
import{dropdownControl}from"../controls/dropdownControl";
1616
import{stringExposingStateControl}from"comps/controls/codeStateControl";
1717
import{BoolControl}from"comps/controls/boolControl";
18+
importReactfrom"react";
1819

1920
constContainer=styled.div<{
2021
$style:timerStyleType|undefined;
@@ -113,7 +114,9 @@ const childrenMap = {
113114
hideButton:BoolControl,
114115
};
115116

116-
constAvatarGroupView=(props:RecordConstructorToView<typeofchildrenMap>&{dispatch:(action:CompAction)=>void;})=>{
117+
typeChildrenType=NewChildren<RecordConstructorToComp<typeofchildrenMap>>;
118+
119+
constTimerCompView=React.memo((props:RecordConstructorToView<typeofchildrenMap>&{dispatch:(action:CompAction)=>void;})=>{
117120
const[startTime,setStartTime]=useState(0)
118121
const[timerState,setTimerState]=useState('stoped')
119122
const[elapsedTime,setElapsedTime]=useState(0)
@@ -219,51 +222,57 @@ const AvatarGroupView = (props: RecordConstructorToView<typeof childrenMap> & {
219222
</ButtonWarrper>
220223
</Container>
221224
);
222-
};
225+
});
223226

224-
letAvatarGroupBasicComp=(function(){
225-
returnnewUICompBuilder(childrenMap,(props,dispatch)=><AvatarGroupView{...props}dispatch={dispatch}/>)
226-
.setPropertyViewFn((children)=>(
227-
<>
228-
{["logic","both"].includes(useContext(EditorContext).editorModeStatus)&&(
229-
<>
230-
<Sectionname={sectionNames.basic}>
231-
{children.timerType.propertyView({
232-
label:trans('timer.timerType')
233-
})}
234-
{children.defaultValue.propertyView({
235-
label:trans('timer.defaultValue')
236-
})}
237-
{children.hideButton.propertyView({
238-
label:trans('timer.hideButton')
239-
})}
240-
</Section>
241-
<Sectionname={sectionNames.interaction}>
242-
{children.onEvent.propertyView()}
243-
{hiddenPropertyView(children)}
244-
{showDataLoadingIndicatorsPropertyView(children)}
245-
</Section>
246-
</>
247-
)}
248-
249-
{["layout","both"].includes(useContext(EditorContext).editorModeStatus)&&(
250-
<>
251-
<Sectionname={sectionNames.style}>
252-
{children.style.getPropertyView()}
253-
</Section>
254-
<Sectionname={sectionNames.animationStyle}hasTooltip={true}>
255-
{children.animationStyle.getPropertyView()}
256-
</Section>
257-
<Sectionname={sectionNames.startButtonStyle}>
258-
{children.startButtonStyle.getPropertyView()}
227+
constTimerCompPropertyView=React.memo((props:{
228+
children:ChildrenType
229+
})=>{
230+
return(
231+
<>
232+
{["logic","both"].includes(useContext(EditorContext).editorModeStatus)&&(
233+
<>
234+
<Sectionname={sectionNames.basic}>
235+
{props.children.timerType.propertyView({
236+
label:trans('timer.timerType')
237+
})}
238+
{props.children.defaultValue.propertyView({
239+
label:trans('timer.defaultValue')
240+
})}
241+
{props.children.hideButton.propertyView({
242+
label:trans('timer.hideButton')
243+
})}
259244
</Section>
260-
<Sectionname={sectionNames.resetButtonStyle}>
261-
{children.resetButtonStyle.getPropertyView()}
245+
<Sectionname={sectionNames.interaction}>
246+
{props.children.onEvent.propertyView()}
247+
{hiddenPropertyView(props.children)}
248+
{showDataLoadingIndicatorsPropertyView(props.children)}
262249
</Section>
263-
</>
264-
)}
265-
</>
266-
))
250+
</>
251+
)}
252+
253+
{["layout","both"].includes(useContext(EditorContext).editorModeStatus)&&(
254+
<>
255+
<Sectionname={sectionNames.style}>
256+
{props.children.style.getPropertyView()}
257+
</Section>
258+
<Sectionname={sectionNames.animationStyle}hasTooltip={true}>
259+
{props.children.animationStyle.getPropertyView()}
260+
</Section>
261+
<Sectionname={sectionNames.startButtonStyle}>
262+
{props.children.startButtonStyle.getPropertyView()}
263+
</Section>
264+
<Sectionname={sectionNames.resetButtonStyle}>
265+
{props.children.resetButtonStyle.getPropertyView()}
266+
</Section>
267+
</>
268+
)}
269+
</>
270+
)
271+
});
272+
273+
letTimerCompBasic=(function(){
274+
returnnewUICompBuilder(childrenMap,(props,dispatch)=><TimerCompView{...props}dispatch={dispatch}/>)
275+
.setPropertyViewFn((children)=><TimerCompPropertyViewchildren={children}/>)
267276
.setExposeMethodConfigs([
268277
{
269278
method:{
@@ -294,7 +303,7 @@ let AvatarGroupBasicComp = (function () {
294303
.build();
295304
})();
296305

297-
exportconstTimerComp=withExposingConfigs(AvatarGroupBasicComp,[
306+
exportconstTimerComp=withExposingConfigs(TimerCompBasic,[
298307
newNameConfig("defaultValue",trans("timer.defaultValue")),
299308
newNameConfig("elapsedTime",trans("timer.elapsedTime")),
300309
newNameConfig("timerState",trans("timer.timerState")),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp