almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

React support for templates #3840

Open TimNZ opened 6 years ago

TimNZ commented 6 years ago

ReactDOM.render() returns null for pure components, so the React example and docs should return '' from the template functions instead of the return value of ReactDOM.render(), for people who will get caught out.

Returning null in a template results in the item id being inserted in addition to React content being rendered.

Alternatively, don't insert the id if null is returned from the template func.

12tp12 commented 6 years ago

@TimNZ solved it? I get the same thing.... thought about ReactDom.createPortal

TimNZ commented 6 years ago
            groupTemplate: function(group,element){
                if (!group) return
                ReactDOM.unmountComponentAtNode(element)
                ReactDOM.render(<GroupTemplate label={group.content}/>,element)
                return ' '   <-----
            },
12tp12 commented 6 years ago

Thanks!