datatrails: in Components, model.useState(), instead of model.state (#88432)

fix: in Components, `model.useState()`, instead of `model.state`

Generally, it is better practice. More succinct.
It could also eliminate subtle state bugs.
This commit is contained in:
Darren Janeczek 2024-05-29 10:29:57 -04:00 committed by GitHub
parent 633486e4f1
commit 763108ce10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 3 deletions

View File

@ -200,7 +200,7 @@ export class DataTrailHistory extends SceneObjectBase<DataTrailsHistoryState> {
// Specifics per step type
styles.stepTypes[stepType],
// To highlight selected step
model.state.currentStep === index ? styles.stepSelected : '',
currentStep === index ? styles.stepSelected : '',
// To alter the look of steps with distant non-directly preceding parent
alternatePredecessorStyle.get(index) ?? '',
// To remove direct link for steps that don't have a direct parent

View File

@ -369,7 +369,7 @@ export class MetricSelectScene extends SceneObjectBase<MetricSelectSceneState> {
</Alert>
)}
<StatusWrapper {...{ isLoading, blockingMessage }}>
<model.state.body.Component model={model.state.body} />
<body.Component model={body} />
</StatusWrapper>
</div>
);

View File

@ -16,9 +16,10 @@ export class SelectMetricAction extends SceneObjectBase<SelectMetricActionState>
};
public static Component = ({ model }: SceneComponentProps<SelectMetricAction>) => {
const { title } = model.useState();
return (
<Button variant="secondary" size="sm" fill="solid" onClick={model.onClick}>
{model.state.title}
{title}
</Button>
);
};