Skip to content

Commit

Permalink
fix: use dangerouslySetInnerHTML to avoid React errors
Browse files Browse the repository at this point in the history
  • Loading branch information
barjin committed Nov 19, 2024
1 parent e0d75f5 commit 0894fc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apify/docusaurus-plugin-typedoc-api",
"version": "4.2.11-2",
"version": "4.2.11-3",
"description": "Docusaurus plugin that provides source code API documentation powered by TypeDoc. ",
"keywords": [
"docusaurus",
Expand All @@ -18,8 +18,8 @@
"types": "./lib/index.d.ts",
"files": [
"assets/**/*",
"python-scripts/**/*",
"lib/**/*",
"python-scripts/**/*",
"src/**/*",
"styles.css"
],
Expand Down
9 changes: 6 additions & 3 deletions packages/plugin/src/components/ApiItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ export default function ApiItem({ readme: Readme, route }: ApiItemProps) {

<Reflection reflection={item} />
{/* The `application/json+typedoc-data;base64` is an base64 encoded JSON object that contains the machine-readable API item data. */}
<script type="application/typedoc-data;base64">{
base64Encode(
<script
// eslint-disable-next-line react/no-danger,react-perf/jsx-no-new-object-as-prop
dangerouslySetInnerHTML={{__html: base64Encode(
JSON.stringify(
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Expand All @@ -224,7 +225,9 @@ export default function ApiItem({ readme: Readme, route }: ApiItemProps) {
groups: getOwnGroupNames(item, reflections),
},
)
)}</script>
)}}
type="application/typedoc-data;base64"
/>
</ApiItemLayout>
</ApiOptionsContext.Provider>
);
Expand Down

0 comments on commit 0894fc0

Please sign in to comment.