unmountComponentAtNode不适用于自定义呈现的组件

时间:2019-03-03 22:58:44

标签: reactjs

问题是当react在根树之外渲染新组件时,我无法处理并卸载:

createInfoWindow = (e, map, place, marker) => {
    let container = 0;
    infoWindow = new window.google.maps.InfoWindow({
        content: '<div id=infoWindow />',
        position: {lat: e.latLng.lat(), lng: e.latLng.lng()},
    });
    infoWindow.addListener('domready', e => {
        ReactDOM.render(<InfoWindow
                ref={this.ref}
                desc={place.description}
                clicked={() => this.onClickHandler(place.id)}/>,
            document.getElementById('infoWindow'))
    });
    infoWindow.open(map, marker);
    // ReactDOM.unmountComponentAtNode(document.getElementById('infoWindow'))
};

enter image description here

0 个答案:

没有答案