Skip to content

Commit

Permalink
fix: add ImageConfigContext to both server and client
Browse files Browse the repository at this point in the history
fix: renderOpts.image is string

fix: cleanup

fix: parse error
  • Loading branch information
JuniorTour committed Feb 5, 2022
1 parent ffeda9c commit cd61d6b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/next/client/image.tsx
Expand Up @@ -7,7 +7,7 @@ import {
VALID_LOADERS,
} from '../server/image-config'
import { useIntersection } from './use-intersection'
import { ImageConfigContext } from '../shared/lib/runtime-image-config-context'
import { ImageConfigContext } from '../shared/lib/image-config-context'

const loadedImageURLs = new Set<string>()
const allImgs = new Map<
Expand Down
3 changes: 1 addition & 2 deletions packages/next/client/index.tsx
Expand Up @@ -38,8 +38,7 @@ import {
trackWebVitalMetric,
} from './streaming/vitals'
import { RefreshContext } from './streaming/refresh'
import { ImageConfigContext } from '../shared/lib/runtime-image-config-context'
import { StyleRegistry } from 'styled-jsx'
import { ImageConfigContext } from '../shared/lib/image-config-context'
import { ImageConfigComplete } from '../server/image-config'

/// <reference types="react-dom/experimental" />
Expand Down
9 changes: 5 additions & 4 deletions packages/next/server/render.tsx
Expand Up @@ -61,8 +61,7 @@ import { DomainLocale } from './config'
import RenderResult from './render-result'
import isError from '../lib/is-error'
import { readableStreamTee } from './web/utils'
import { ImageConfigContext } from '../shared/lib/runtime-image-config-context'
import { ImageConfigComplete } from './image-config'
import { ImageConfigContext } from '../shared/lib/image-config-context'

let optimizeAmp: typeof import('./optimize-amp').default
let getFontDefinitionFromManifest: typeof import('./font-utils').getFontDefinitionFromManifest
Expand Down Expand Up @@ -234,7 +233,7 @@ export type RenderOptsPartial = {
serverComponents?: boolean
customServer?: boolean
crossOrigin?: string
images: ImageConfigComplete
images: string
}

export type RenderOpts = LoadComponentsReturnType & RenderOptsPartial
Expand Down Expand Up @@ -717,7 +716,9 @@ export async function renderToHTML(
value={(moduleName) => reactLoadableModules.push(moduleName)}
>
<StyleRegistry registry={jsxStyleRegistry}>
<ImageConfigContext.Provider value={images}>
<ImageConfigContext.Provider
value={images ? JSON.parse(images) : null}
>
{children}
</ImageConfigContext.Provider>
</StyleRegistry>
Expand Down

0 comments on commit cd61d6b

Please sign in to comment.