Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Create VirtualElement from React node #395

Open
johnwiseheart opened this issue Jun 21, 2019 · 0 comments · Fixed by jupyterlab/lumino#29 · May be fixed by #437
Open

Create VirtualElement from React node #395

johnwiseheart opened this issue Jun 21, 2019 · 0 comments · Fixed by jupyterlab/lumino#29 · May be fixed by #437

Comments

@johnwiseheart
Copy link

Hi!

I would like to render a react element beside the title of the tab for each tab in my tabbar. I have looked into extending the Renderer of the tab bar, but cannot see a way to render a React Node instead of a regular VirtualElement.

Ideally, it would be great to do something like:

class MyRenderer extends TabBar.Renderer {
    public renderIcon = (data: TabBar.IRenderData<any>): VirtualElement => {
        return <Icon icon={IconNames.HOME} />;
    }
}

but I figured since phosphor does not use the React virtualdom, perhaps something like

class MyRenderer extends TabBar.Renderer {
    public renderIcon = (data: TabBar.IRenderData<any>): VirtualElement => {
        return ReactDOM.render(<Icon icon={IconNames.HOME} />, data.node);
    }
}

May be possible. But then I realised that VirtualElements are not actual elements. Is there any way for renderIcon to create an actual HTMLElement, or more broadly to create a VirtualElement from a React node?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant