Skip to content

Commit c953b72

Browse files
committed
revert useContext() description
1 parent 7b9e7d6 commit c953b72

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

packages/flutter_hooks/lib/src/framework.dart

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ abstract class HookState<R, T extends Hook<R>> with Diagnosticable {
296296
/// the build is unconditional and the `shouldRebuild()` call is skipped.
297297
bool shouldRebuild() => true;
298298

299-
/// Mark the associated [context] as **potentially** needing to rebuild.
299+
/// Mark the associated [HookWidget] as **potentially** needing to rebuild.
300300
///
301301
/// As opposed to [setState], the rebuild is optional and can be cancelled right
302302
/// before [build] is called, by having [shouldRebuild] return false.
@@ -623,19 +623,11 @@ class _StatefulHookElement extends StatefulElement with HookElement {
623623
_StatefulHookElement(StatefulHookWidget hooks) : super(hooks);
624624
}
625625

626-
/// Returns the [HookElement] that is currently running its `build()` method.
627-
///
628-
/// Throws an error if no hook widget is currently building.
629-
///
630-
/// Most Hook functions call [use] to construct a [Hook] object,
631-
/// but `useContext()` only returns a [BuildContext], so the requirement to
632-
/// make calls unconditionally does not apply here.
633-
/// But for the sake of convention, the best practice is to invoke `use*` functions
634-
/// unconditionally across the board.
626+
/// Obtains the [BuildContext] of the building [HookWidget].
635627
BuildContext useContext() {
636628
assert(
637629
HookElement._currentHookElement != null,
638-
'`useContext` can only be called while a Hook widget is building.',
630+
'`useContext` can only be called from the build method of HookWidget',
639631
);
640632
return HookElement._currentHookElement!;
641633
}

0 commit comments

Comments
 (0)