Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
b149144f
Commit
b149144f
authored
3 weeks ago
by
deep1401
Browse files
Options
Downloads
Patches
Plain Diff
Remove the onChange useeffect and place it whenever the change happens itself
parent
f9aafdef
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/renderer/components/Experiment/Widgets/CustomEvaluationWidget.tsx
+7
-10
7 additions, 10 deletions
.../components/Experiment/Widgets/CustomEvaluationWidget.tsx
with
7 additions
and
10 deletions
src/renderer/components/Experiment/Widgets/CustomEvaluationWidget.tsx
+
7
−
10
View file @
b149144f
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
Select
,
Select
,
Option
,
Option
,
}
from
'
@mui/joy
'
;
}
from
'
@mui/joy
'
;
import
{
on
}
from
'
node:events
'
;
type
EvaluationField
=
{
type
EvaluationField
=
{
name
:
string
;
name
:
string
;
...
@@ -14,7 +15,6 @@ type EvaluationField = {
...
@@ -14,7 +15,6 @@ type EvaluationField = {
};
};
const
CustomEvaluationWidget
=
(
props
:
WidgetProps
<
any
>
)
=>
{
const
CustomEvaluationWidget
=
(
props
:
WidgetProps
<
any
>
)
=>
{
const
{
id
,
value
,
onChange
,
disabled
,
readonly
}
=
props
;
const
{
id
,
value
,
onChange
,
disabled
,
readonly
}
=
props
;
...
@@ -57,18 +57,13 @@ const CustomEvaluationWidget = (props: WidgetProps<any>) => {
...
@@ -57,18 +57,13 @@ const CustomEvaluationWidget = (props: WidgetProps<any>) => {
}
}
},
[
value
]);
},
[
value
]);
// Propagate state changes upstream.
React
.
useEffect
(()
=>
{
onChange
(
evalMetrics
);
},
[
evalMetrics
]);
const
handleAddField
=
()
=>
{
const
handleAddField
=
()
=>
{
setEval
Metrics
(
[
const
updated
Metrics
=
[
...
evalMetrics
,
...
evalMetrics
,
{
name
:
''
,
expression
:
''
,
return_type
:
'
boolean
'
}
{
name
:
''
,
expression
:
''
,
return_type
:
'
boolean
'
}
]);
];
setEvalMetrics
(
updatedMetrics
);
onChange
(
updatedMetrics
);
};
};
const
handleFieldChange
=
(
const
handleFieldChange
=
(
...
@@ -80,11 +75,13 @@ const CustomEvaluationWidget = (props: WidgetProps<any>) => {
...
@@ -80,11 +75,13 @@ const CustomEvaluationWidget = (props: WidgetProps<any>) => {
i
===
index
?
{
...
evaluation
,
[
field
]:
newValue
}
:
evaluation
i
===
index
?
{
...
evaluation
,
[
field
]:
newValue
}
:
evaluation
);
);
setEvalMetrics
(
updated
);
setEvalMetrics
(
updated
);
onChange
(
updated
);
};
};
const
handleRemoveField
=
(
index
:
number
)
=>
{
const
handleRemoveField
=
(
index
:
number
)
=>
{
const
updated
=
evalMetrics
.
filter
((
_
,
i
)
=>
i
!==
index
);
const
updated
=
evalMetrics
.
filter
((
_
,
i
)
=>
i
!==
index
);
setEvalMetrics
(
updated
);
setEvalMetrics
(
updated
);
onChange
(
updated
);
};
};
return
(
return
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment