Fix the bug that violates "Rules of Hooks"

This commit is contained in:
porink0424
2024-08-28 15:28:46 +09:00
parent 80c23a3fa2
commit 49b2370529
3 changed files with 9 additions and 6 deletions
+3 -2
View File
@@ -11,11 +11,12 @@ export const GraphEdf: FC<{
studies: StudyDetail[]
objectiveId: number
}> = ({ studies, objectiveId }) => {
const theme = useTheme()
const colorTheme = usePlotlyColorTheme(theme.palette.mode)
if (useBackendRender()) {
return <GraphEdfBackend studies={studies} />
} else {
const theme = useTheme()
const colorTheme = usePlotlyColorTheme(theme.palette.mode)
return (
<PlotEdf
studies={studies}
@@ -23,6 +23,9 @@ export const GraphHyperparameterImportance: FC<{
studyId,
})
const theme = useTheme()
const colorTheme = usePlotlyColorTheme(theme.palette.mode)
if (useBackendRender()) {
return (
<GraphHyperparameterImportanceBackend
@@ -32,8 +35,6 @@ export const GraphHyperparameterImportance: FC<{
/>
)
} else {
const theme = useTheme()
const colorTheme = usePlotlyColorTheme(theme.palette.mode)
return (
<Card>
<CardContent>
@@ -14,11 +14,12 @@ import { useBackendRender, usePlotlyColorTheme } from "../state"
export const GraphSlice: FC<{
study: StudyDetail | null
}> = ({ study = null }) => {
const theme = useTheme()
const colorTheme = usePlotlyColorTheme(theme.palette.mode)
if (useBackendRender()) {
return <GraphSliceBackend study={study} />
} else {
const theme = useTheme()
const colorTheme = usePlotlyColorTheme(theme.palette.mode)
return <PlotSlice study={study} colorTheme={colorTheme} />
}
}