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

[🐞] Actual value for useContext() can not be found, when using nested context provider components, that dynamically shows children using <Slot/> #7186

Open
genki opened this issue Dec 20, 2024 · 3 comments
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@genki
Copy link
Contributor

genki commented Dec 20, 2024

Which component is affected?

Qwik Runtime

Describe the bug

I found this issue when I am trying to write some abstract components acting as control flow such like <If/>, <Then/>

Here is what I wanted to do.

export default component$(() => {
  const users:User[] = [
    {name:"Foo"},
    {name:"Bar", age:40},
  ]
  return <div>
    {users.map((u,i) => {
      return <UserCtx user={u}>
        <div>
          <span>Name:</span><span><UserAttr attr="name"/></span>
          <IfUserAttr attr="age">
            <span>Age:</span><span><Then/></span>
          </IfUserAttr>
        </div>
      </UserCtx>
    })}
  </div>;
});

This is almost working but the <Then/> caused unexpected error that I have titled.
While the detail is in the reproduction URL, it might be the dynamic conditional <Slot/> inside the multiple hierarchical context provider components is not treated nicely.

It may be relating to #3531

Reproduction

https://qwik.dev/playground/#f=7VdNS8NAEL37K0oOpYXFerAgaZMQBSEG9CCCEHIotoFiaaVNoRL2vztvdrOZxlj0pmAvm25m33y9nZlI0ozHV02mQF7VkEC16KbuHp8f9iXRWjXkFI81T09SjrP%2FhHYYcFBQs3w7KUzoP13yyLd9BNFneaMVbWyahnQwpdpEl3e%2B670u3jcF49HZiB%2ByNHevncX0Lu0R7gLlz64TAx6X5ZZMf9tNCSLuQHZbyzUVWsKJWgZZPHUG2%2BDUjCD9Xgz7zwwZXsqDdbp9h7EdDjxMCB7lx4knRYew84dOLAvI2wNAuSkPOCIucQVU7fPiQ0Q7MnaUF2uj4mmFoJu7D2IQgfRQqkPcjvUhgF2p%2BUEABxVip%2F0mKWnobDa6eZYKZK20hkuTWSjiJQNiTjpoVlgU1LLmpnRZV5Li9zpjZKjr0DzBQqd8%2BiqnSaEsRGRX3K%2FVSobL7Pf7ItUuQNSk1y1etZwQBgovkuKTBhv477SdJjw7Zm6Wk4KMa1nFNcO73Ww8reTO9WzrKVQQ%2F%2FKC3%2BSCw%2FiUMcIMek4D%2B2CwV0unEb9auL5OEA2qvRYl1uHY%2F%2FiUCe%2BhfzriZ7PDEMwqpCrwYKE3Cq2MBBAENKLkgCclaiUxOXasA6npxBw1oMJ0%2FpxzzcH6aDb0UNNqJP47%2B1%2Ft7B8

Steps to reproduce

Please visit the link above and it causes the error.

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M2
    Memory: 57.00 MB / 24.00 GB
    Shell: 3.6.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.12.1 - /opt/homebrew/opt/node@20/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.5.0 - /opt/homebrew/opt/node@20/bin/npm
    pnpm: 9.11.0 - /opt/homebrew/bin/pnpm
    bun: 1.1.26 - ~/.bun/bin/bun
  Browsers:
    Chrome: 131.0.6778.205
    Safari: 17.6
  npmPackages:
    @builder.io/partytown: 0.10.2 => 0.10.2 
    @builder.io/qwik: workspace:^ => 1.10.0 
    @builder.io/qwik-city: workspace:^ => 1.10.0 
    typescript: 5.4.5 => 5.4.5 
    undici: * => 6.6.2 
    vite: 5.3.5 => 5.3.5

Additional Information

No response

@genki genki added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Dec 20, 2024
@gioboa
Copy link
Member

gioboa commented Dec 20, 2024

Thanks for your feedback. Can you check the behaviour with v2 please?

@gioboa
Copy link
Member

gioboa commented Dec 20, 2024

Thanks for checking, would you like to create a failing v2 test for this?
You can take inspiration by this commit
The v2 branch is build/v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants