Problem
The cfg macros that check about the os does not works into component functions, preceded with #[function_component(App)].
Steps To Reproduce
In a component function :
#[function_component(App)]
pub fn app() -> Html {
}
You can't use any cfg macro or any conditional compiling macro.
e.g.
#[cfg(target_os = "windows")]
html! {
<section class="sidebar leftbar">
<h2>{"On Windows"}</h2>
</section>
}
#[cfg(not(target_os = "windows"))]
html! {
<section class="sidebar leftbar">
<h2>{"Not on Windows"}</h2>
</section>
}
The cfg!(target_os = "xxx") boolean macro also returns false whatever the parameter provided.
The statement env::var("CARGO_CFG_TARGET_OS") returns env::var("CARGO_CFG_TARGET_OS")
⚠️ This only occurs into functions components, that are preceded by :
#[function_component(App)]
or into functions that are called from a component function.
Expected behavior
The statement #[cfg(target_os = "windows")] should hide to the compiler the following statement.
The expression cfg!(target_os = "windows") should return true or false depending of the current platform.
The expression env::var("CARGO_CFG_TARGET_OS")
Environment:
- Yew version: 0.20.0
- Rust version: 1.65.0
- Target, if relevant: wasm32-unknown-unknown
- Build tool, if relevant: tauri
- OS, if relevant: MacOS
- Browser and version, if relevant: Using tauri webpack
Questionnaire
Problem
The cfg macros that check about the os does not works into component functions, preceded with
#[function_component(App)].Steps To Reproduce
In a component function :
You can't use any cfg macro or any conditional compiling macro.
e.g.
The
cfg!(target_os = "xxx")boolean macro also returns false whatever the parameter provided.The statement
env::var("CARGO_CFG_TARGET_OS")returnsenv::var("CARGO_CFG_TARGET_OS")#[function_component(App)]or into functions that are called from a component function.
Expected behavior
The statement
#[cfg(target_os = "windows")]should hide to the compiler the following statement.The expression
cfg!(target_os = "windows")should return true or false depending of the current platform.The expression
env::var("CARGO_CFG_TARGET_OS")Environment:
Questionnaire