Closed mike-lloyd03 closed 2 years ago
Okay I think I figured out the second part of this.
match resp.status() {
400 => {
store.dispatch().reduce(|s| {
s.msg = Some("Failed".to_string());
s.lvl = Some("error".to_string());
})
}
_ => history.push(Route::Keys),j
But some clarification on the first error would be greatly appreciated.
Apologies, this is my fault. What version are you using? I've been meaning to add a disclaimer to the book, as it is only relevant to the master branch at the moment. If you need to use latest release, please see the readme and examples on this branch https://github.com/intendednull/yewdux/tree/0.7.0
If you don't have any other dependencies requiring latest Yew 0.19, I suggest using the master branch of both Yew and Yewdux, as there have been many major improvements in Yewdux's features and ergonomics. Just need Yew 0.20 to release in order to release Yewdux 0.8
Went ahead and released 0.8 (though it's missing a feature). Try using that instead
Awesome thanks for the quick response. I'll update to 0.8 and give it another shot.
Okay I updated to 0.8.1 but I still can't derive the Store
trait.
#[derive(Clone, Default, PartialEq, Eq, Store)]
pub struct Notification {
pub msg: Option<String>,
pub lvl: Option<String>,
}
trait impl with the same name found
and
the trait bound `components::notifier::Notification: yewdux::store::Store` is not satisfied
perhaps two different versions of crate `yewdux` are being used?
It looks like yewdux-functional
is still dependent on yewdux
0.7.0 so cargo is loading both versions and it's causing a conflict.
Try removing yewdux-functional. It's now merged into yewdux as of 0.8
That did it. Working good now. The ergonomics are a bit better with 0.8 now too. I just cut a hundred or so lines of code out of my project with this. Thanks!
I'm trying to create a store for popping up notifications to the user. But trying to follow the docs does not work for me.
From https://intendednull.github.io/yewdux/example.html:
But when I implement this, I get the following error:
I see there is a
yewdux-functional
crate on crates.io but this isn't mentioned anywhere in the yewdux docs. Using the example from docs.rs seems to work.But I'm not sure how to update this state from another component. In the example below, if the form submission received a 400 response from the request to the backend, I'd like to display a notification in the
<Notifier />
component which is rendered at the top of the tree.But the compiler tells me
cannot assign to data in an 'Rc'
. Any guidance would be appreciated and I can open a PR to update the docs once I understand what I should do here.Thank you.