问题描述:

I want to render one component on to body or any other div, inside another component while it rendering.

My code here is below :

var React = require('react');

var ReactDOM = require('react-dom');

import PopupSmall from './PopupSmall.js';

class SwitchAccount extends React.Component{

constructor(){

super();

this.state = {showPopup:false};

}

changeAccount(e){

if(!this.state.showPopup){

this.setState({showPopup:true});

}

}

popupChange(){

this.setState({showPopup:false});

this.props.onChangeAccount();

}

render(){

var popupView;

if(this.state.showPopup){

popupView = <PopupSmall popupCallBack={this.popupChange.bind(this)} itemList={this.props.agencies} />

}

return (

<a href="javascript:;" onClick={this.changeAccount.bind(this)}>

<i className="fa fa-plus-circle"></i>

<span> Switch Account</span>

//so here i need to render popupview component on body.

// {PopupView, document.getElementById('modal')} or on document.body like so

// how can i do it here

</a>

)

}

}

export default SwitchAccount;

In the above code, there is a popupView var which refers to PopupSmall Component, I want to render this component on to body. How could I achieve this task.

Help me out!

相关阅读:
Top