Skip to content

html_nested! inserts extra pair of brackets  #2157

@Madoshakalaka

Description

@Madoshakalaka

Problem
html_nested! macro wraps the VChild with an extra pair of brackets and there's no way to fix it on the user's end.

Steps To Reproduce
Minimal code to produce:

use yew::{prelude::*};
use yew::virtual_dom::VChild;


#[function_component(MyOtherComponent)]
pub fn my_other_component() -> Html {
    html! {}
}

fn make_other_component() -> VChild<MyOtherComponent>{
    html_nested!(<MyOtherComponent/>)
}


#[function_component(MyComponent)]
fn my_component() -> Html {
    html!{
        {make_other_component()}
    }
}

fn main(){
    yew::start_app::<MyComponent>();
}

Then cargo check will give the following output:

warning: unnecessary braces around block return value
  --> src\bin\html_nested_mininal.rs:12:19
   |
12 |     html_nested!(<MyOtherComponent/>)
   |                   ^^^^^^^^^^^^^^^^ help: remove these braces
   |
   = note: `#[warn(unused_braces)]` on by default

Environment:

  • Yew version: [master]
  • Rust version: [1.56.0]

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions