Skip to content

Commit

Permalink
fix(gatsby-plugin-image): Preload lazy-hydrator (#28690)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic authored Dec 22, 2020
1 parent 8ff6245 commit 6af620c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/gatsby-plugin-image/gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const React = require("react")

const { LaterHydrator } = require(".")

exports.wrapRootElement = ({ element }) => {
return (
<LaterHydrator>
{element}
</LaterHydrator>
)
}
10 changes: 10 additions & 0 deletions packages/gatsby-plugin-image/src/components/later-hydrator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from "react"
export function LaterHydrator({
children,
}: React.PropsWithChildren<{}>): React.ReactNode {
React.useEffect(() => {
import(`./lazy-hydrate`)
}, [])

return children
}
1 change: 1 addition & 0 deletions packages/gatsby-plugin-image/src/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export {
export { Placeholder } from "./components/placeholder"
export { MainImage } from "./components/main-image"
export { StaticImage } from "./components/static-image"
export { LaterHydrator } from "./components/later-hydrator"
export { getImage, getSrc, useGatsbyImage } from "./components/hooks"
export {
generateImageData,
Expand Down

0 comments on commit 6af620c

Please sign in to comment.