React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.
MIT License
3.07k
stars
175
forks
source link
Making the `keys` optional for the `useCallback` hook #368
Maybe I'm missing something, but why does the keys property on the useCallback have to be required? The useMemonized has its keys optional and it defaults to an empty list.
Below is the current implementation of the useCallback hook:
T useCallback<T extends Function>(
T callback,
List<Object?> keys,
) {
return useMemoized(() => callback, keys);
}
I wonder if we could change the keys property optional and default to an empty list like the following:
T useCallback<T extends Function>(
T callback, [
List<Object?> keys = const <Object>[],
]) {
return useMemoized(() => callback, keys);
}
Maybe I'm missing something, but why does the
keys
property on theuseCallback
have to be required? TheuseMemonized
has itskeys
optional and it defaults to an empty list.Below is the current implementation of the
useCallback
hook:I wonder if we could change the
keys
property optional and default to an empty list like the following: