I am working on a tasklist react page. I created a different element called "Task". The following code is of Task.js and CompletedTask.js has also somewhat similar code.
import React,{useState} from 'react'
import Checkbox from '@material-ui/core/Checkbox';
import CompletedTask from './CompletedTask.js';
export default function Task(props){
const task_text = props.text;
const complete_text = useState({task_text});
const taskComplete = (event) => {
event.preventDefault();
let doneTask = document.getElementById('done-task-list')
let new_done_task = document.createElement( <CompletedTask text={complete_text} />);
doneTask.appendChild(new_done_task);
}
return (
<>
<Checkbox
defaultChecked={false}
color="default"
inputProps={{ 'aria-label': 'checkbox with default color' }}
onClick={taskComplete}
/>
{task_text}
</>
)
}
CompleteTask is another react element that I build and what it does is it disables the checkbox and the text color is different. I am unable to append this CompleteTask element to the end of my div (with id 'done-task'). The error is with using document.createElement. Is there any alternate way I can append my self created element?