0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-07 22:52:39 +00:00

Fix mutating HTMLErrors directly instead of setState

This commit is contained in:
Trevor Buckner
2025-09-09 22:19:43 -04:00
parent 6f2c397574
commit 8a0f350c47

View File

@@ -126,9 +126,7 @@ const EditPage = (props) => {
const handleTextChange = (text) => { const handleTextChange = (text) => {
//If there are HTML errors, run the validator on every change to give quick feedback //If there are HTML errors, run the validator on every change to give quick feedback
if(HTMLErrors.length) if(HTMLErrors.length)
HTMLErrors = Markdown.validate(text); setHTMLErrors(Markdown.validate(text));
setHTMLErrors(HTMLErrors);
setCurrentBrew((prevBrew) => ({ ...prevBrew, text })); setCurrentBrew((prevBrew) => ({ ...prevBrew, text }));
}; };
@@ -139,9 +137,7 @@ const EditPage = (props) => {
const handleSnipChange = (snippet)=>{ const handleSnipChange = (snippet)=>{
//If there are HTML errors, run the validator on every change to give quick feedback //If there are HTML errors, run the validator on every change to give quick feedback
if(HTMLErrors.length) if(HTMLErrors.length)
HTMLErrors = Markdown.validate(snippet); setHTMLErrors(Markdown.validate(snippet));
setHTMLErrors(HTMLErrors);
setCurrentBrew((prevBrew) => ({ ...prevBrew, snippets: snippet })); setCurrentBrew((prevBrew) => ({ ...prevBrew, snippets: snippet }));
}; };