Replies: 2 comments 3 replies
-
You can use ref.read in a build method. Your widget will just not rebuild if the value of the provider changes. This is usually not what you want, hence the warning in the doc. As for your question, I would say that as long as |
Beta Was this translation helpful? Give feedback.
-
Don't. You should instead use final value = ref.watch(...);
useEffect(() {
print(value);
}, [value]); |
Beta Was this translation helpful? Give feedback.
-
The doc mentioned that we cannot use
ref.read
inside build method directly.But how about
ref.read
insideuseEffect
oruseMemoized
from flutter_hooks package? Is it OK?https://riverpod.dev/ja/docs/essentials/combining_requests#refread-%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89
If it is an anti-pattern, I would appreciate if you could also tell me the reason.
Code Example
Beta Was this translation helpful? Give feedback.
All reactions