Skip to content

Commit

Permalink
Use html-to-react instead of dangerouslySetInnerHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
Studio384 committed Apr 5, 2023
1 parent aa2ee4f commit adce2e8
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 39 deletions.
39 changes: 34 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"@mui/system": ">=5.x",
"react": ">=16.x"
},
"dependencies": {
"@hedgedoc/html-to-react": "1.4.6"
},
"devDependencies": {
"@twbs/fantasticon": "2.6.0",
"@types/react": "18.0.33",
Expand Down
136 changes: 105 additions & 31 deletions site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/ValkyrieIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IValkyrieIcon } from "./";
import { Box, SxProps } from "@mui/system";
import { keyframes } from "@emotion/react";
import convertHtmlToReact from "@hedgedoc/html-to-react";

interface ValkyrieProps {
icon: IValkyrieIcon;
Expand Down Expand Up @@ -61,8 +62,8 @@ export default function ValkyrieIcon({
},
...(Array.isArray(sx) ? sx : [sx])
]}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: icon.data }}
/>
>
{convertHtmlToReact(icon.data)}
</Box>
);
}

0 comments on commit adce2e8

Please sign in to comment.