I have an element that I want to add to the end of my body:
const nRecipe =
<div id = "container">
<div className="recipe App" id="four"
onClick={this.toggleRecipeList.bind(this)}>{this.state.recipeName}
</div>
<div style={{display:"none"}}>
{this.state.value4.split(",").map((e)=>
<p>{e}</p>)}
<button onClick={this.deleteRecipe}>Delete</button>
<button name="4" onClick={this.openEditBox}>Edit</button>
</div></div>
The button that creates this element is as follows:
<button onClick={this.newRecipe.bind(this)}>Enter</button>
The function is defined as follows:
newRecipe(){
document.body.appendChild({nRecipe});}
I have also tried
newRecipe(){
document.body.insertAdjacentElement("beforeend", {nRecipe});}
The error messages I get is TypeError:
Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
&&
TypeError: Failed to execute 'insertAdjacentElement' on 'Element':
parameter 2 is not of type 'Element'.
I wasn't able to find any question that answers this directly. I do not wish to toggle between showing and hiding elements, I want a button that can create elements defined by jsx using document object model methods.