Custom Component- SVG not working

Rafael Oliveir1
Tera Contributor

Hi all. 

 

I was retrying to create a new custom component that uses the tag svg, but for some reason it's not working. Already did several things to make it work, but nothing seems to fix the problem. 

Is there any reason to not use svg on the custom component project? 

 

Below you can see the code in the inde.js file 

Thanks

 

 

import {createCustomElement} from '@servicenow/ui-core';
import snabbdom from '@servicenow/ui-renderer-snabbdom';
import styles from './styles.scss';
import React from 'react'

const view = (state, {updateState}) => {
	return (
		<div>
		  <h1>My SVG in React</h1>
		  <svg
			width="100"
			height="100"
			viewBox="0 0 100 100"
			xmlns="http://www.w3.org/2000/svg"
		  >
			<circle cx="50" cy="50" r="40" stroke="black" strokeWidth="3" fill="red" />
		  </svg>
		</div>
	  );
};




createCustomElement('loading-component', {
	renderer: {type: snabbdom},
	view,
	styles
});

 

 

1 REPLY 1

Dmitrii Blinov
Tera Contributor

For those who also face the same problem here is the answer: https://www.dylanlindgren.com/2022/12/09/in-line-svgs-in-next-experience-components/