-
Notifications
You must be signed in to change notification settings - Fork 161
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
Update TodoMVC example to use Context API #279
Comments
I can work on this |
awesome! |
Apologies, I'm removing my assignment as I'm really busy and not able to work on it. |
No worries |
I'd love to work on this! Just got oriented around the API in my own project 😃 |
I'm hitting an issue while refactoring and I created this repo to reproduce the issue using the smallest amount of code. The problem arises with application events that update vectors like the following taken from the linked repo: let handle_click = cloned!((state) => move |_event: Event| {
let new_count: Vec<Signal<i32>> = state.counts
.get()
.as_ref()
.clone()
.into_iter()
.chain(Some(Signal::new(0)))
.collect();
state.counts.set(new_count)
}); Which is the same as the code for adding a todo: fn add_todo(&self, title: String) {
let new_todos: Vec<Signal<Todo>> = self.todos
.get()
.as_ref()
.clone()
.into_iter()
.chain(Some(Signal::new(Todo {
title,
completed: false,
id: Uuid::new_v4(),
})))
.collect();
debug!("new todos: {:?}", new_todos);
self.todos.set(new_todos)
} Calling both of those while using
|
Yeah that does seem like a bug in Sycamore. This also reminds me that the context not found error should definitely be improved. The location should point to the usage instead of sycamore internals. Sorry for the trouble |
No trouble at all! Thanks for taking a look, it's exciting to possibly find a bug and help improve things 😃 And I think I follow your explanation, though how come in my example repo the action that doesnt update a collection in the same component works? |
Does what it says on the tin. Closes sycamore-rs#279
Does what it says on the tin. Closes #279
The TodoMVC example is a good reference for learning Sycamore. It should be updated to use the context API to prevent "prop-drilling"
The text was updated successfully, but these errors were encountered: