Skip to content

Commit 6af620c

Browse files
authored
fix(gatsby-plugin-image): Preload lazy-hydrator (#28690)
1 parent 8ff6245 commit 6af620c

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const React = require("react")
2+
3+
const { LaterHydrator } = require(".")
4+
5+
exports.wrapRootElement = ({ element }) => {
6+
return (
7+
<LaterHydrator>
8+
{element}
9+
</LaterHydrator>
10+
)
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as React from "react"
2+
export function LaterHydrator({
3+
children,
4+
}: React.PropsWithChildren<{}>): React.ReactNode {
5+
React.useEffect(() => {
6+
import(`./lazy-hydrate`)
7+
}, [])
8+
9+
return children
10+
}

packages/gatsby-plugin-image/src/index.browser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export {
66
export { Placeholder } from "./components/placeholder"
77
export { MainImage } from "./components/main-image"
88
export { StaticImage } from "./components/static-image"
9+
export { LaterHydrator } from "./components/later-hydrator"
910
export { getImage, getSrc, useGatsbyImage } from "./components/hooks"
1011
export {
1112
generateImageData,

0 commit comments

Comments
 (0)