I'm still learning react, so this may just be because I don't fully understand what I'm doing yet. The formattedText field is just a temporary text that the user creates from a button click. I want to create a running history of this field, so I created historyText.
function App() {
const [formattedText, setFormattedText] = useState([]);
const [historyText, setHistoryText] = useState([]);
In my button click action, I'm setting the formattedText:
setFormattedText(tempComp);
And I thought I could just append it to my history:
setHistoryText(historyText+tempComp);
But it doesn't work, all I get is [object Object],[object Object],[object Object],[object Object],[object Object]
as my output.
** Clarification: the reason this may look strange because I'm storing html in the strings and wanted it to show as html. Here's how I'm building tempComp:
tempComp.push(<p><b>{dResult[y].dp5}</b></p>);
Different lines are formatted differently, so I couldn't just use a split to add in a <p>
for example.