intendednull / yewdux

Ergonomic state management for Yew applications
https://intendednull.github.io/yewdux/
Apache License 2.0
319 stars 31 forks source link

reduce() hangs forever #23

Closed jan-br closed 2 years ago

jan-br commented 2 years ago

Hi, Soo I am trying to create a very small test application with yewdux-functional. This is my root component with a simple state struct.

#[function_component(Test)]
pub fn test() -> Html {
    let state = use_store::<BasicStore<TestState>>();
    state.dispatch().reduce(|_| {});
    html! {
        {"Test123"}
    }
}

#[derive(Clone, Debug, PartialEq, Default)]
pub struct TestState {}

But as soon as I include the .reduce(|_|{}) call, my browser tab starts to load forever and (I assume) busy waits one of my cores completely. Am I not allowed to mutate the state directly in a function without callbacks etc? This seems like a very trivial usecase to me.

jan-br commented 2 years ago

Alright, dont mind this issue. I just realized, that the render call will of course be reevaluated, after reduce is executed, which will result in an infinite loop. oopsie