Uncaught TypeError: Cannot read properties of null (reading 'render') Turbo-rails + Flowbite
honeypc opened this issue · 0 comments
honeypc commented
Describe the bug
The issue happened while I was using the custom render template Turbo.renderStreamMessage(HTML)
at https://github.com/themesberg/flowbite/blob/main/src/index.turbo.ts#L22
Expected behavior
So we can handle the issue by updating like this
addEventListener('turbo:before-stream-render', (event: CustomEvent) => {
if(event.detail) {
const originalRender = event.detail.render;
event.detail.render = function (streamElement: Element) {
originalRender(streamElement);
document.dispatchEvent(afterRenderEvent);
};
}
});