---
title: "Comment by Shad Mirza on \"React: Context, Custom hooks and multiple components problem\" | Hashnode"
description: "Context provider &quot;provides&quot; the context to all it&#39;s children no matter how deep they are. Since Button was outside the provider and not a children"
url: "https://hashnode.com/posts/react-context-custom-hooks-and-multiple-components-problem/60e99b946d962b01bdecc2d2/comment/60e99ee46d962b01bdecc36f"
---

[Discussion](https://hashnode.com/posts/react-context-custom-hooks-and-multiple-components-problem/60e99b946d962b01bdecc2d2)

Comment [React: Context, Custom hooks and multiple components problem](https://hashnode.com/posts/react-context-custom-hooks-and-multiple-components-problem/60e99b946d962b01bdecc2d2)

[Jul 10, 2021](https://hashnode.com/posts/react-context-custom-hooks-and-multiple-components-problem/60e99b946d962b01bdecc2d2/comment/60e99ee46d962b01bdecc36f)

Context provider "provides" the context to all it's children no matter how deep they are. Since `Button` was outside the provider and not a children of provider, it wasn't able to identify which "context" you're talking when you said `useContext` inside the custom hook.

Always make sure that the component which is using "context" is inside the context "Provider"

[Nic](https://hashnode.com/@nicm42)

[Jul 10, 2021](https://hashnode.com/posts/react-context-custom-hooks-and-multiple-components-problem/60e99b946d962b01bdecc2d2/comment/60e99ee46d962b01bdecc36f#reply-60e99ff5c551f16b0f847be2)

I'm still a bit confused though, because the custom hook isn't inside the context provider. Is it that any component that calls the custom hook must be inside the context provider, if the custom hook uses the context?
