Skip to content

useTresContext must be used together with useTresContextProvider #89092

Closed Answered by justinrds2001
LNNying asked this question in Programming Help
Discussion options

You must be logged in to vote

For anyone still getting this error. Tres JS documentation reads the following:

WARNING
useTresContext can be only be used inside of a TresCanvas since this component acts as the provider for the context data.

This means useTresContext can only be used in a "sub-component" that is passed as a slot for TresCanvas:
App.vue:

<template>
  <TresCanvas
    render-mode="manual"
  >
    <SubComponent />
  </TresCanvas>
</template>

SubComponent.vue:

<script lang="ts" setup>
import { useTresContext } from '@tresjs/core'

const context = useTresContext()
</script>

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by LiteBrite82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Programming Help Programming languages, open source, and software development.
3 participants