A component with props including a Signal cannot be put in a different module to the parent component.
Steps To Reproduce
Minimal sample:
use dioxus::prelude::*;
fn RootComponent() -> Element {
let number = use_signal(|| 42);
rsx! {
components::MyComponent {
number: number,
}
}
}
mod components {
use dioxus::prelude::*;
#[component]
pub(super) fn MyComponent(number: ReadOnlySignal<u64>) -> Element {
rsx! {
div { "{number}" }
}
}
}
The error I'm seeing:
error[E0631]: type mismatch in function arguments
--> ui/src/lib.rs:44:9
|
43 | / rsx! {
44 | | components::MyComponent {
| | ^^^^^^^^^^^^^^^^^^^^^^^ expected due to this
45 | | number: number,
46 | | }
47 | | }
| |_____- required by a bound introduced by this call
...
53 | #[component]
| ------------ found signature defined here
|
= note: expected function signature `fn(MyComponentPropsWithOwner) -> _`
found function signature `fn(MyComponentProps) -> _`
= note: required for `fn(MyComponentProps) -> Option<VNode> {MyComponent}` to implement `dioxus::prelude::ComponentFunction<MyComponentPropsWithOwner>`
Expected behavior
The above sample compiles like it does when the two components are in the same module.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment:
Dioxus version: 0.5-alpha.0
Rust version: 1.76.0
OS info: Ubuntu Linux
App platform: desktop
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
[x] I don't have time to fix this right now, but maybe later
Problem
A component with props including a
Signal
cannot be put in a different module to the parent component.Steps To Reproduce
Minimal sample:
The error I'm seeing:
Expected behavior
The above sample compiles like it does when the two components are in the same module.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment:
desktop
Questionnaire