brianegan / flutter_redux

A library that connects Widgets to a Redux Store
MIT License
1.65k stars 219 forks source link

store dispatch method cause rebuild unexpectedly #201

Closed Nerogee closed 3 years ago

Nerogee commented 3 years ago

I use flutter_redux along with saga middleware. I notice that this store.dispatch method will cause widget rebuild even there is not setState explicitly called.

I used the StoreConnector like this `Widget build(BuildContext context){

print('This widget is built'); return StoreConnector( converter: _ViewModel.fromStore, builder: (BuildContext context, vm){ return MyWidgetHere(); } ) }`

From what I observed, the dispatch method will trigger the rebuild process once it's called. Or maybe I didn't follow the best practice?

brianegan commented 3 years ago

Hey there -- please add distinct: true to your StoreConnector and ensure the _ViewModel class implements ==. That should prevent the Widget from rebuilding!