Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Fix infinite loading in VariantComponent (#10267)
Browse files Browse the repository at this point in the history
* Use `useOptionalComponent` instead of `useComponent`

* Use `getOptional` instead of `useOptional`

---------

Co-authored-by: Gheric Speiginer <[email protected]>
  • Loading branch information
CITIZENDOT and speigg authored May 29, 2024
1 parent e135beb commit 0e66e47
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import DeblurIcon from '@mui/icons-material/Deblur'
import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next'

import { useComponent } from '@etherealengine/ecs/src/ComponentFunctions'
import { getOptionalMutableComponent, useComponent } from '@etherealengine/ecs/src/ComponentFunctions'
import { Entity, UndefinedEntity } from '@etherealengine/ecs/src/Entity'
import { AssetLoader } from '@etherealengine/engine/src/assets/classes/AssetLoader'
import { AssetType } from '@etherealengine/engine/src/assets/enum/AssetType'
Expand Down Expand Up @@ -96,11 +96,12 @@ export const VariantNodeEditor: EditorComponentType = (props: { entity: Entity }
const { t } = useTranslation()
const entity = props.entity
const variantComponent = useComponent(entity, VariantComponent)
const modelComponent = useComponent(entity, ModelComponent)
const previewIndex = useHookstate(0)

const setPreview = (index: number) => {
previewIndex.set(index)
const modelComponent = getOptionalMutableComponent(entity, ModelComponent)
if (!modelComponent) return
modelComponent.src.set(variantComponent.levels[index].src.value)
}

Expand Down

0 comments on commit 0e66e47

Please sign in to comment.