Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useTres doesnt get updated on subcomponent #209

Closed
alvarosabu opened this issue Apr 18, 2023 · 1 comment · Fixed by #210
Closed

useTres doesnt get updated on subcomponent #209

alvarosabu opened this issue Apr 18, 2023 · 1 comment · Fixed by #210
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed v2 How TresJS should have been from start ☺️

Comments

@alvarosabu
Copy link
Member

Describe the bug
When use useTres composable inside a sub-component to obtain the state, this state never gets updated. Curiously it does get updated when accessed from cientos or any other package

Reproduction
Please provide a link using this template on Stackblitz

Steps
Steps to reproduce the behavior:

  1. Go to reproduction link
  2. Open console.
  3. See that the console inside of the sphere gives a default state with mostly all undefined, but the console on the parent using templateRef context is updated with the correct value of state

Expected behavior
State using useTres should provide correct updated state

Screenshots
If applicable, add screenshots to help explain your problem.

System Info
Output of npx envinfo --system --npmPackages '{vite,@tresjs/*, three, vue}' --binaries --browsers

 System:
    OS: Linux 5.0 undefined
    CPU: (3) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
  npmPackages:
    @tresjs/cientos: ^2.0.0-beta.3 => 2.0.0-beta.3 
    @tresjs/core: ^2.0.0-beta.9 => 2.0.0-beta.9 
    vite: ^4.2.2 => 4.2.2 

Additional context
Add any other context about the problem here.

@alvarosabu alvarosabu added bug Something isn't working help wanted Extra attention is needed v2 How TresJS should have been from start ☺️ labels Apr 18, 2023
@alvarosabu alvarosabu added this to Tres Apr 18, 2023
@alvarosabu alvarosabu changed the title useTres doesnt get updated useTres doesnt get updated on subcomponent Apr 18, 2023
Tinoooo added a commit that referenced this issue Apr 18, 2023
@Tinoooo
Copy link
Contributor

Tinoooo commented Apr 18, 2023

The cause for this problem is that useTres is not provided to components below TresScene. That is the case, because the context is lost when the scene is mounted here. It works in cientos, because cientos does not use the symbol but the string 'useTres'. I think we should make it use the symbol, for better typing and to avoid potential collisions.

@Tinoooo Tinoooo moved this to In Progress in Tres Apr 18, 2023
@Tinoooo Tinoooo self-assigned this Apr 18, 2023
@Tinoooo Tinoooo linked a pull request Apr 18, 2023 that will close this issue
@Tinoooo Tinoooo closed this as completed Apr 19, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tres Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed v2 How TresJS should have been from start ☺️
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants