0
나는 툴바 구성 요소와 기본 페이지 구성 요소에 텍스트, 이미지 및 비디오 요소를 추가하는 3 가지 옵션을 가지고 있으며 기본 페이지 구성 요소에 클릭 핸들을 작성하고이 이벤트 핸들러를 툴바 구성 요소에 전달합니다.dom reactjs에 다양한 유형의 요소를 추가하는 방법은 무엇입니까?
내 간단한 생각은 요소의 유형을 정의하는 매개 변수가 있지만 그 요소를 렌더링하는 방법을 모른다는 것입니다.
어떻게하면됩니까?
class ToolbarContainer extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div id="toolbarSection">
<div class="option" onClick={this.props.handleActionsClick("image")}>new Image</div>
<div class="option" onClick={this.props.handleActionsClick("text")}>new Text</div>
<div class="option" onClick={this.props.handleActionsClick("shape")}>new Shape</div>
</div>
);
}
}
class Page extends React.Component {
constructor(props) {
super(props);
}
handleActionsClick(type){
switch(type){
case "image":
//How can i render the <img/>?
case "text":
case "video":
}
}
render() {
return();
}
}