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

Cannot access props from VComp #819

Closed
jstarry opened this issue Dec 21, 2019 · 5 comments
Closed

Cannot access props from VComp #819

jstarry opened this issue Dec 21, 2019 · 5 comments

Comments

@jstarry
Copy link
Member

jstarry commented Dec 21, 2019

The only way to access props from a virtual component node is through the intermediary VChild node. This makes it impossible to access props of a child component which is a VNode type.

Proposed Solution

Add get_properties and get_properties_mut methods to VComp and refactor away VChild

@trivigy
Copy link
Contributor

trivigy commented Dec 21, 2019

Seems like some sort of a design deficiency. Shouldn't every node by definition have a way to retrieve its properties and its children? Even if those are unset.

@trivigy
Copy link
Contributor

trivigy commented Dec 23, 2019

@jstarry any suggestions on how to resolve this? I am working on a material based component library and this is definitely a blocker for me. I want to fix this. I went through the html macro and understand how that works. The issue as I see it has to do with VNode not allowing for properties and children. There is a whole different approach for that with vcomp. If you give me some guidance on how this could be solved I will take a crack at it.

The way I see things is that even the basic VNode should have children and properties. Even if they are ultimately just empty vec!

@MuhannadAlrusayni
Copy link
Contributor

..component library and this is definitely a blocker for me

Same here.

It would be great if a component can access and manipulate it's children props.

@trivigy
Copy link
Contributor

trivigy commented Dec 23, 2019

@MuhannadAlrusayni This can be done already. SNIPPET

This issue was created because of an edge case situation. When for loop is used, the nesting type checking fails.

html! {
    <div class="main">
        <h1>{ "Nested List Demo" }</h1>
        <List on_hover=on_hover.clone()>
            <ListHeader text="Calling all Rusties!" on_hover=on_hover.clone() />
           {for (0..5).map(|column| {
                return html! {
                    <ListItem name="Rustin" on_hover=on_hover.clone() />
                }
            })}
            <ListItem hide={true} name="Rustaroo" on_hover=on_hover.clone() />
            <ListItem name="Rustifer" on_hover=on_hover.clone()>
                <span>{"Hello!"}</span>
            </ListItem>
        </List>
        {self.view_last_hovered()}
    </div>
}

@jstarry
Copy link
Member Author

jstarry commented Jan 6, 2020

Fixed in #843

@jstarry jstarry closed this as completed Jan 6, 2020
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

3 participants