-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Sending messages during the rendering phase can cause infinite update loops #933
Comments
#2040 documents this behaviour so I think the documentation label can be removed now. |
Closing this because it's documented behaviour now. If there's a need for the scheduler to be changed, a new issue should be opened. |
let (store, dispatch) = use_store::<Store>();
let history = use_navigator().unwrap();
let projects = use_state(Vec::new);
if store.token.is_empty() {
dispatch.reduce_mut(move |store| {
store.error_message = "Please create account or login.".to_owned()
});
history.push(&Route::Login)
}
{
let projects = projects.clone();
use_effect(move || {
spawn_local(async move {
match get_projects(&store.token).await {
Ok(user_projects) => projects.set(user_projects),
Err(APIError::NotAuthenticated) => dispatch.reduce_mut(move |store| {
store.token = String::new();
store.email = String::new();
}),
Err(error) => {
log!(error.to_string())
}
}
});
});
}; I try to prevent loop using |
Suggested changes
Option 1. Update the scheduler queue to prevent this
Option 2. Update documentation to warn against this behaviour
The text was updated successfully, but these errors were encountered: