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

Nested slots cannot access parent Context #639

Open
alzayon opened this issue Aug 23, 2022 · 0 comments
Open

Nested slots cannot access parent Context #639

alzayon opened this issue Aug 23, 2022 · 0 comments

Comments

@alzayon
Copy link

alzayon commented Aug 23, 2022

Nested slots cannot access parent Context values

Please see the code below

Parent

defmodule Parent do

slot default
...
def render(assigns) do
    ~F"""
    <Context
      put={__MODULE__, orientation: true}>
      <Child><#slot /></Child>
     </Context>
     """
end

Child

defmodule Child do
...
slot default

def render(assigns) do
    ~F"""
    <div>
    <#slot />
     </div>
     """
end

Some other component

defmodule SomeComponent do
...
slot default

def render(assigns) do
    ~F"""
     <Context get={Parent, orientation: orientation}>
        <Parent>
             {orientation} --> This has no value
         </Parent>
     </Context>
     """
end

In the example above, the orientation has no value. The solution is to define <Context put={}inside the child component as well.

SomeComponent should be able to access the values coming from the Parent component's context.

Your Environment

Surface: v0.7
LiveView: v0.17
Elixir: v1.13.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant