Skip to content

Commit

Permalink
fix: rename to ImageConfigContext
Browse files Browse the repository at this point in the history
  • Loading branch information
JuniorTour committed Feb 4, 2022
1 parent 9a8e348 commit 37ded21
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/next/client/image.tsx
Expand Up @@ -7,7 +7,7 @@ import {
VALID_LOADERS,
} from '../server/image-config'
import { useIntersection } from './use-intersection'
import { RuntimeImageConfigContext } from '../shared/lib/runtime-image-config-context'
import { ImageConfigContext } from '../shared/lib/runtime-image-config-context'

const loadedImageURLs = new Set<string>()
const allImgs = new Map<
Expand Down Expand Up @@ -401,7 +401,7 @@ export default function Image({
isLazy = false
}

setRuntimeImageConfig(useContext(RuntimeImageConfigContext))
setRuntimeImageConfig(useContext(ImageConfigContext))

if (process.env.NODE_ENV !== 'production') {
if (!src) {
Expand Down
11 changes: 5 additions & 6 deletions packages/next/server/render.tsx
Expand Up @@ -63,7 +63,8 @@ import { DomainLocale } from './config'
import RenderResult, { NodeWritablePiper } from './render-result'
import isError from '../lib/is-error'
import { readableStreamTee } from './web/utils'
import { RuntimeImageConfigContext } from '../shared/lib/runtime-image-config-context'
import { ImageConfigContext } from '../shared/lib/runtime-image-config-context'
import { ImageConfigComplete } from './image-config'

let Writable: typeof import('stream').Writable
let Buffer: typeof import('buffer').Buffer
Expand Down Expand Up @@ -238,7 +239,7 @@ export type RenderOptsPartial = {
serverComponents?: boolean
customServer?: boolean
crossOrigin?: string
images: string
images: ImageConfigComplete
}

export type RenderOpts = LoadComponentsReturnType & RenderOptsPartial
Expand Down Expand Up @@ -721,11 +722,9 @@ export async function renderToHTML(
value={(moduleName) => reactLoadableModules.push(moduleName)}
>
<StyleRegistry registry={jsxStyleRegistry}>
<RuntimeImageConfigContext.Provider
value={images ? JSON.parse(images) : null}
>
<ImageConfigContext.Provider value={images}>
{children}
</RuntimeImageConfigContext.Provider>
</ImageConfigContext.Provider>
</StyleRegistry>
</LoadableContext.Provider>
</HeadManagerContext.Provider>
Expand Down
4 changes: 2 additions & 2 deletions packages/next/shared/lib/runtime-image-config-context.ts
Expand Up @@ -4,9 +4,9 @@ import {
imageConfigDefault,
} from '../../server/image-config'

export const RuntimeImageConfigContext =
export const ImageConfigContext =
React.createContext<ImageConfigComplete>(imageConfigDefault)

if (process.env.NODE_ENV !== 'production') {
RuntimeImageConfigContext.displayName = 'RuntimeImageConfigContext'
ImageConfigContext.displayName = 'ImageConfigContext'
}

0 comments on commit 37ded21

Please sign in to comment.