Looking for some guidance here, maybe this isn't the library for me, but I'd like to make it work if possible. I'm implementing a collapsible tree chart, similar to this. I've already got a working version that makes an API call on componentDidMount to grab the tree data, but would like to be able to update the tree to show/hide nodes and display different information based on state/props. Anyway, on to the code.
const zoomListener = d3Zoom().scaleExtent([0.1, 1]).on('zoom', zoom);
const faux = this.connectFauxDOM('div.renderedD3', 'chart');
/* pre react-faux-dom
const svg = select(document.getElementsByClassName('target')[0])
.append('svg')
.attr('width', '100%')
.attr('height', '100%')
.attr('class', 'orgChart')
.call(zoomListener);
*/
const svg = select(faux)
.append('svg')
.attr('width', '100%')
.attr('height', '100%')
.attr('class', 'orgChart')
.call(zoomListener);
const g = svg.append('g').dispatch('click') // this line is throwing a TypeError: Cannot read property 'createEvent' of undefined;
Throwing in a breakpoint, the error is happening because window.document is undefined. Which I suppose is to be expected since I'm appending to faux. I can get my initial node to render if I remove the .dispatch('click'). Am I missing something obvious? Or is react-faux-dom not what I'm looking for? Thanks!
Looking for some guidance here, maybe this isn't the library for me, but I'd like to make it work if possible. I'm implementing a collapsible tree chart, similar to this. I've already got a working version that makes an API call on
componentDidMount
to grab the tree data, but would like to be able to update the tree to show/hide nodes and display different information based on state/props. Anyway, on to the code.Throwing in a breakpoint, the error is happening because
window.document
is undefined. Which I suppose is to be expected since I'm appending tofaux
. I can get my initial node to render if I remove the.dispatch('click')
. Am I missing something obvious? Or isreact-faux-dom
not what I'm looking for? Thanks!