Skip to content

[Vue warn]: provide() can only be used inside setup(). #1228

@Jungzl

Description

@Jungzl

Describe the bug

vue@3.5.25 bring a warning about the usage of provide() though it doesn't cause bugs rn.
ref: vuejs/core#13954

I think it is the useTresContextProvider inside onMounted

onMounted(() => {
const existingCanvas = canvasRef as Ref<HTMLCanvasElement>
context.value = useTresContextProvider({
scene: scene.value as TresScene,
canvas: existingCanvas,
windowSize: props.windowSize ?? false,
rendererOptions: props,
})

Reproduction

https://stackblitz.com/edit/vitejs-vite-uay94k5d?file=src%2FApp.vue

Steps to reproduce

open devtools to see the warning

System Info

System:
    OS: Windows 11 10.0.26200
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700
    Memory: 820.05 MB / 15.77 GB
  Binaries:
    Node: 24.11.1
    Yarn: 1.22.22
    npm: 11.6.2
    pnpm: 10.23.0
    bun: 1.3.3
  Browsers:
    Chrome: 142.0.7444.176
    Edge: Chromium (140.0.3485.54)
    Firefox: 145.0.1
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @tresjs/cientos: ^5.1.1 => 5.1.1 
    @tresjs/core: ^5.1.1 => 5.1.1 
    rolldown-vite:  7.2.5 
    three: ^0.181.2 => 0.181.2 
    vue: ^3.5.25 => 3.5.25

Used Package Manager

pnpm

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions