I was able to create a custom renderer that took a callback function that returned a react element. The params of the callback can be all the data from the source and it renders the element.
My renderer function is defined like this
const renderReactFn = (cb: (data: unknown) => ReactElement) => function(instance, TD, row) {
const data = instance.getSourceDataAtRow(row)
const container = document.createElement('div');
const root = ReactDOM.createRoot(container);
const el = cb(data);
root.render(el);
TD.innerHTML = '';
TD.appendChild(container);
TD.style.backgroundColor = 'transparent';
// ... do other stuff
return TD;
}
Lastly, in my column definition you can do something like this:
{
renderer: renderReactFn((data) => {
// do something with the data...
return <MyComponent />;
})
}
This might not be the most ideal solution but it’s working for us.
Edit: changed element to a div
so that the browser doesn’t complain about block elements being within inline elements.