Merged in fix/SW-1831-accordion-error-key-prop-is-missing (pull request #1496)
fix(SW-1831): add fragment * fix(SW-1831): add fragment * fix(SW-1831): move fragment to nodesToHtml * fix(SW-1831): remove import * fix(SW-1831): add getUniqueId Approved-by: Erik Tiekstra Approved-by: Matilda Landström
This commit is contained in:
@@ -29,12 +29,7 @@ export default async function ParkingAmenity({
|
|||||||
<ParkingInformation key={data.type} parking={data} />
|
<ParkingInformation key={data.type} parking={data} />
|
||||||
))}
|
))}
|
||||||
{parkingPageUrl && (
|
{parkingPageUrl && (
|
||||||
<Button
|
<Button theme="base" intent="secondary" asChild>
|
||||||
className={styles.parkingPageLink}
|
|
||||||
theme="base"
|
|
||||||
intent="secondary"
|
|
||||||
asChild
|
|
||||||
>
|
|
||||||
<Link
|
<Link
|
||||||
href={`/${parkingPageUrl}`}
|
href={`/${parkingPageUrl}`}
|
||||||
color="burgundy"
|
color="burgundy"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export default function JsonToHtml({
|
|||||||
if (!Array.isArray(nodes) || !nodes.length) {
|
if (!Array.isArray(nodes) || !nodes.length) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={cx(styles.container, className)}>
|
<section className={cx(styles.container, className)}>
|
||||||
{nodesToHtml(nodes, embeds, renderOptions).filter(Boolean)}
|
{nodesToHtml(nodes, embeds, renderOptions).filter(Boolean)}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import React from "react"
|
||||||
|
|
||||||
import { renderOptions } from "./renderOptions"
|
import { renderOptions } from "./renderOptions"
|
||||||
|
|
||||||
import styles from "./jsontohtml.module.css"
|
import styles from "./jsontohtml.module.css"
|
||||||
@@ -130,6 +132,13 @@ export function nodeToHtml(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUniqueId(node: RTENode) {
|
||||||
|
if ("uid" in node) {
|
||||||
|
return node.uid
|
||||||
|
}
|
||||||
|
return node.id
|
||||||
|
}
|
||||||
|
|
||||||
export function nodesToHtml(
|
export function nodesToHtml(
|
||||||
nodes: RTENode[],
|
nodes: RTENode[],
|
||||||
embedsArray: Node<Embeds>[],
|
embedsArray: Node<Embeds>[],
|
||||||
@@ -137,7 +146,11 @@ export function nodesToHtml(
|
|||||||
) {
|
) {
|
||||||
const embeds = groupEmbedsByUid(embedsArray)
|
const embeds = groupEmbedsByUid(embedsArray)
|
||||||
const fullRenderOptions = { ...renderOptions, ...overrideRenderOptions }
|
const fullRenderOptions = { ...renderOptions, ...overrideRenderOptions }
|
||||||
return nodes.map((node) => nodeToHtml(node, embeds, fullRenderOptions))
|
return nodes.map((node, index) => (
|
||||||
|
<React.Fragment key={getUniqueId(node) ?? `node-${index}`}>
|
||||||
|
{nodeToHtml(node, embeds, fullRenderOptions)}
|
||||||
|
</React.Fragment>
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makeCssModuleCompatibleClassName(
|
export function makeCssModuleCompatibleClassName(
|
||||||
|
|||||||
Reference in New Issue
Block a user