I am trying to use the browsers native tooling for creating svg elements within a react component. The error I get when creating an element and placing that variable in the render method is the following:
Objects are not valid as a React child (found: [object Element])
I can get the element to the page with the following but I know it is not the best way. What would be the proper way for handling this case?
import React from 'react'
export default class Circle extends React.Component {
componentDidMount() {
let canvas = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
canvas.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'ellipse'))
document.getElementById('element').appendChild(canvas)
}
render() {
return (
<div id='element'></div>
);
}
}