Skip to content

Commit 3a4666c

Browse files
authored
Set SvgIcon href without __dangerouslySetInnerHtml
React 15.x now supports the xlink:href SVG attribute (as xlinkHref)
1 parent 4b1e94a commit 3a4666c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/scripts/Icon.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ export default class Icon extends Component {
150150
},
151151
className
152152
);
153-
/* eslint-disable max-len */
154-
const useHtml = `<use xlink:href="${getAssetRoot()}/icons/${category}-sprite/svg/symbols.svg#${icon}"></use>`;
153+
154+
const useHtml = `${getAssetRoot()}/icons/${category}-sprite/svg/symbols.svg#${icon}`;
155155
return (
156156
<svg
157157
className={ iconClassNames }
158158
aria-hidden
159-
dangerouslySetInnerHTML={ { __html: useHtml } }
159+
<use xlinkHref={useHtml}></use>
160160
ref={ node => (this.svgIcon = node) }
161161
style={ style }
162162
{...props}

0 commit comments

Comments
 (0)