silverwolf-x/project / packages /third-parties /src /ThirdPartyScriptEmbed.tsx
silverwolf-x's picture
download
raw
1.24 kB
'use client'
import React, { useEffect } from 'react'
export type ScriptEmbed = {
html?: string | null
height?: string | number | null
width?: string | number | null
children?: React.ReactElement | React.ReactElement[]
dataNtpc?: string
}
export default function ThirdPartyScriptEmbed({
html,
height = null,
width = null,
children,
dataNtpc = '',
}: ScriptEmbed) {
useEffect(() => {
if (dataNtpc) {
// performance.mark is being used as a feature use signal. While it is traditionally used for performance
// benchmarking it is low overhead and thus considered safe to use in production and it is a widely available
// existing API.
performance.mark('mark_feature_usage', {
detail: {
feature: `next-third-parties-${dataNtpc}`,
},
})
}
}, [dataNtpc])
return (
<>
{/* insert script children */}
{children}
{/* insert html */}
{html ? (
<div
style={{
height: height != null ? `${height}px` : 'auto',
width: width != null ? `${width}px` : 'auto',
}}
data-ntpc={dataNtpc}
dangerouslySetInnerHTML={{ __html: html }}
/>
) : null}
</>
)
}

Xet Storage Details

Size:
1.24 kB
·
Xet hash:
a0c2811c6c3c86ade54ae218d1a615b9534e56efc563897ad0dc17ff16b404e5

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.