-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Bad state: Type mismatch between hooks: - previous hook: TabControllerHook - new hook: _SingleTickerProviderHook #217
Comments
It's a regression. But I'm a bit busy at the moment. If it's urgent for you, feel free to make a PR |
I was just messing around with a custom hook and I happen to come across the same issue. e.g:
this works
Or maybe I'm just totally lost 😆 |
Hmm, even if I dont directly return it from the build method, I still get an error while using a periodic timer through setState
|
Any update on this issue? |
No not really. I'd suggest using your hooks outside of void useSomething() {
final state = useState();
use(MyHook());
} instead of: class MyHookState extends HookState<T> {
@override
void build(context) {
final state = useState();
}
} That achieves the same effect. Alternatively, you can try to make a PR to fix this issue. This is a low priority for me |
Closing in favor of #215 |
I'm getting the error while I'm using tabController with Hookwidget. below is my TabControllerHook
class TabControllerHook extends Hook {
final int length;
final int initialIndex;
const TabControllerHook(this.length, this.initialIndex);
@OverRide
HookState<TabController, TabControllerHook> createState() {
return _TabControllerHookState();
}
}
class _TabControllerHookState extends HookState<TabController, TabControllerHook> {
@OverRide
build(BuildContext context) {
final tickerProvider = useSingleTickerProvider();
final controller = useMemoized(() => TabController(length: hook.length, vsync: tickerProvider, initialIndex: hook.initialIndex), [tickerProvider]);
}
}
** and use the above hook in my home screen like below**
class Home extends HookWidget {
TabController tabController;
HomeViewModel viewModel;
@OverRide
Widget build(BuildContext context){
viewModel = useProvider(homeViewModel);
tabController = use(TabControllerHook(2, 0));
}
}
I don't understand from where this issue is generating?
The text was updated successfully, but these errors were encountered: