themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS

Home Page:https://flowbite.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError: Cannot read properties of null (reading 'render') Turbo-rails + Flowbite

honeypc opened this issue · comments

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

Screenshots
Screenshot 2024-03-24 191544

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);
        };
    }
});