I want to render two components ( TodoDone and TodoRemaining ) in this TodoDisplay component
The default render should be TodoRemaining but somehow there should be a onClick handler to render TodoDone component.
Can anyone suggest a way to achieve it ?
import React, { useState, useEffect } from "react";
import TodoRemaining from "../TodoRemaining/TodoRemaining";
import TodoDone from "../TodoDone/TodoDone";
import { DoneTodoProvider } from "../Context/DoneTodoContext";
const TodoDisplay = () => {
const [isPreview, setIsPreview] = useState(true);
if (isPreview) {
return (
<div>
<DoneTodoProvider>
<TodoRemaining />
</DoneTodoProvider>
</div>
);
} else {
return (
<DoneTodoProvider>
<TodoDone />
</DoneTodoProvider>
);
}
};
export default TodoDisplay;