diff --git a/src/HOCs/imgixProvider.jsx b/src/HOCs/imgixProvider.jsx index 436af75e..7cd84525 100644 --- a/src/HOCs/imgixProvider.jsx +++ b/src/HOCs/imgixProvider.jsx @@ -9,11 +9,7 @@ const ImgixContext = createContext() * @returns Hook that gets context value from the nearest`ImgixProvider`. */ function useImgixContext() { - const context = useContext(ImgixContext) - if (context === undefined) { - console.error("useImgixContext must be used within a ImgixProvider") - } - return context + return useContext(ImgixContext) } /** @@ -27,6 +23,9 @@ function useImgixContext() { function ImgixProvider({children, ...reactImgixProps}) { const value = reactImgixProps + if ( children == null || children.length < 1) { + console.error("ImgixProvider must have at least one Imgix child component") + } return {children} }