Skip to content

Commit

Permalink
Add more code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Apr 19, 2020
1 parent 2320134 commit 113d1fa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hooks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,13 @@ export function useCallback(callback, args) {
*/
export function useContext(context) {
const provider = currentComponent.context[context._id];
// We could skip this, but we need to call getHookState here, make
// the devtools aware of the hook.
// We could skip this call here, but than we'd not call
// `options._hook`. We need to do that in order to make
// the devtools aware of this hook.
const state = getHookState(currentIndex++, 9);
// The devtools needs access to the context object to
// be able to pull of the default value when no provider
// is present in the tree.
state._context = context;
if (!provider) return context._defaultValue;
// This is probably not safe to convert to "!"
Expand Down

0 comments on commit 113d1fa

Please sign in to comment.