ranile / material-yew

Yew wrapper for Material Web Components
https://material-yew.rm.rs
Apache License 2.0
230 stars 35 forks source link

Stale event listener when using MatTopAppBarFixed in a function component #21

Closed ncpenke closed 2 years ago

ncpenke commented 2 years ago

Great work putting together this library. I found it informative both in understanding yew, and also as a useful reference for using material with yew.

I'm using MatDrawer and MatTopAppBarFixed in a way similar to the website source except as a function component. I was running into a problem with the the onnavigationiconclick callback. I'm using the callback to update a bool state created via the use_state_eq hook to track the drawer visibility. I found that the older bool state was being used when the callback was called.

After digging into this further, it seemed like the nav_listener in the MatTopAppBarFixed Component trait implementation could be stale if the onnavigationiconclick property changed.

Assuming, this is a bug and not a user error, below is the commit which fixed this . If you're interested, I can create a PR. Thanks!

https://github.com/ncpenke/material-yew/commit/b086652e28ba7c00511afe9fab89ff2511b6efbd

ranile commented 2 years ago

I'd appreciate a PR