-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9de36c
commit b9441b9
Showing
16 changed files
with
328 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
import React, { useContext, createContext } from 'react' | ||
import React, { useContext, createContext } from "react"; | ||
|
||
const ImgixContext = createContext() | ||
const ImgixContext = createContext(); | ||
|
||
/** | ||
* `useImgixContext()` tries to invoke `React.useContext()`. If no context | ||
* is available, this function returns `undefined`. | ||
* is available, this function returns `undefined`. | ||
* @returns The context defined by the closest parent `ImgixProvider`. | ||
*/ | ||
function useImgixContext() { | ||
return useContext(ImgixContext) | ||
return useContext(ImgixContext); | ||
} | ||
|
||
/** | ||
* Creates a Provider component that passes `reactImgixProps` as the Context | ||
* for child components who use the `useImgixContext()` custom hook or | ||
* Creates a Provider component that passes `reactImgixProps` as the Context | ||
* for child components who use the `useImgixContext()` custom hook or | ||
* `React.useContext()` API. | ||
* @param {React.Element <typeof Component>} children | ||
* @param {Object} reactImgixProps | ||
* @param {React.Element <typeof Component>} children | ||
* @param {Object} reactImgixProps | ||
* @returns React.Element | ||
*/ | ||
function ImgixProvider({children, ...reactImgixProps}) { | ||
const value = reactImgixProps | ||
function ImgixProvider({ children, ...reactImgixProps }) { | ||
const value = reactImgixProps; | ||
|
||
if ( children == null || children.length < 1) { | ||
console.error("ImgixProvider must have at least one Imgix child component") | ||
if (children == null || children.length < 1) { | ||
console.error("ImgixProvider must have at least one Imgix child component"); | ||
} | ||
return <ImgixContext.Provider value={value}>{children}</ImgixContext.Provider> | ||
return ( | ||
<ImgixContext.Provider value={value}>{children}</ImgixContext.Provider> | ||
); | ||
} | ||
|
||
export {ImgixProvider, useImgixContext} | ||
export { ImgixProvider, useImgixContext }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from "./shouldComponentUpdateHOC"; | ||
export * from "./imgixProvider" | ||
export * from "./imgixProvider"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,4 +89,4 @@ export const PARAMS_EXP_MAP = Object.freeze({ | |
// Extra | ||
height: "h", | ||
width: "w", | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.